[ https://issues.apache.org/jira/browse/GROOVY-8338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16323530#comment-16323530 ]
Daniel Sun commented on GROOVY-8338: ------------------------------------ The following code still fails when running on Java9 {code} $ java -Xmx32m -version java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode) $ javac -J-Xmx32m -version javac 9.0.1 {code} {code:java} assert [2, 3, 4] == Stream.of(1, 2, 3).map(e -> e + 1).collect(Collectors.toList()); {code} https://travis-ci.org/apache/groovy/jobs/327967597 {code} groovy.transform.stc.LambdaTest > testMethodCall FAILED java.lang.IncompatibleClassChangeError: Method java.util.stream.Stream.of([Ljava/lang/Object;)Ljava/util/stream/Stream; must be InterfaceMethodref constant at Test1.p1(TestScript0.groovy:15) at Test1.main(TestScript0.groovy:9) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:103) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1299) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1047) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:835) at Test1.invokeMethod(TestScript0.groovy) at org.codehaus.groovy.runtime.InvokerHelper$1.run(InvokerHelper.java:456) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:445) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:483) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) at groovy.test.GroovyAssert.assertScript(GroovyAssert.java:83) at groovy.util.GroovyTestCase.assertScript(GroovyTestCase.java:203) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:169) at groovy.transform.stc.LambdaTest.testMethodCall(LambdaTest.groovy:24) {code} > Calling Stream.of from groovy class in JDK 9 fails > -------------------------------------------------- > > Key: GROOVY-8338 > URL: https://issues.apache.org/jira/browse/GROOVY-8338 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime > Affects Versions: 2.4.12 > Reporter: Marcus Nylander > Assignee: Jochen Theodorou > Fix For: 2.4.14 > > > Trying to call Stream.of from groovy class (groovy version 2.4.12) using JDK > 9 (jdk 9 181) fails. > Example: > {code} > package test > import java.util.stream.Stream > class B { > static void main(String[] args) { > Stream.of("1").forEach({ println(it) }) > } > } > {code} > The code above fails with: > Exception in thread "main" java.lang.IncompatibleClassChangeError: Method > java.util.stream.Stream.of(Ljava/lang/Object;)Ljava/util/stream/Stream; must > be InterfaceMethodref constant > at java_util_stream_Stream$of.call(Unknown Source) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) > at test.B.main(B.groovy:7) > The same occurs for other interface static methods also: > {code} > public interface D { > static D of(String s) { > return new D() { > }; > } > } > class C { > static void main(String[] args) { > D.of("1") > } > } > {code} > Also fails with: > Exception in thread "main" java.lang.IncompatibleClassChangeError: Method > test.D.of(Ljava/lang/String;)Ltest/D; must be InterfaceMethodref constant > at test.D$of.call(Unknown Source) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) > at test.C.main(C.groovy:7) > Running with JDK 8 works fine. -- This message was sent by Atlassian JIRA (v6.4.14#64029)