groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Oberstar <ajobers...@gmail.com>
Subject Re: Problem with Groovy 1.8.9 and Java 1.8.0
Date Thu, 23 Apr 2015 00:31:06 GMT
Groovy 2.3 was the first to introduce Java 8 support (see the release notes
linked below). You may be running into one of the incompatibilities they
addressed in that version.

http://www.groovy-lang.org/releasenotes/groovy-2.3.html

Andrew Oberstar

On Wed, Apr 22, 2015 at 7:26 PM W. Craig Trader <craig.trader@gmail.com>
wrote:

> The following code works with Groovy 1.8.9 and Java 1.7.0_71, but fails
> with Java 1.8.0_25 on Mac OS X:
>
> #! /usr/bin/env groovy
>
> class FooIterator implements Iterator<Integer> {
>
>     int supplied
>     int count
>
>     FooIterator( int size ) {
>         supplied = 0
>         count = size
>     }
>
>     boolean hasNext() { return supplied < count }
>
>     Integer next() {
>         if (!hasNext() ) throw new NoSuchElementException()
>         return nextFoo( supplied++ )
>     }
>
>     Integer nextFoo( int position ) { throw new
> UnsupportedOperationException() }
>
>     void remove() { throw new UnsupportedOperationException() }
> }
>
> def getMyFooIterator( int size ) {
> return new FooIterator( size ) {
> Integer nextFoo( int pos ) {
> return Integer.valueOf( pos )
> }
> }
> }
>
> def foos = getMyFooIterator( 5 )
> foos.each { println it }
>
>
> When I run it on Java 8, I get this:
>
> $ groovy -v
> Groovy Version: 1.8.9 JVM: 1.8.0_25 Vendor: Oracle Corporation OS: Mac OS X
> $ ./IteratorTest.groovy
> Caught: java.lang.VerifyError: (class: IteratorTest$1, method:
> super$1$forEachRemaining signature: (Ljava/util/function/Consumer;)V)
> Illegal use of nonvirtual function call
> java.lang.VerifyError: (class: IteratorTest$1, method:
> super$1$forEachRemaining signature: (Ljava/util/function/Consumer;)V)
> Illegal use of nonvirtual function call
> at IteratorTest.getMyFooIterator(IteratorTest.groovy:26)
> at IteratorTest.run(IteratorTest.groovy:33)
>
>
> It works fine with Groovy 2.4.3, but unfortunately I'm somewhat stuck with
> 1.8.9 for now, because (1) it's what OrientDB is currently built against,
> and (2) Groovy 1.8.9 is significantly faster for my application than 2.4.3.
> In the interim, I'm falling back to Java 1.7.0.
>
> - Craig -
>
> PS: I signed up with the Apache Jira so I could report this as a bug, but
> apparently new users aren't allowed to report bugs.
>
> - C -
>

Mime
View raw message