groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "W. Craig Trader" <craig.tra...@gmail.com>
Subject Problem with Groovy 1.8.9 and Java 1.8.0
Date Thu, 23 Apr 2015 00:24:08 GMT
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