Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8338

Calling Stream.of from groovy class in JDK 9 fails

    XMLWordPrintableJSON

Details

    Description

      Trying to call Stream.of from groovy class (groovy version 2.4.12) using JDK 9 (jdk 9 181) fails.
      Example:

      package test
      
      import java.util.stream.Stream
      
      class B {
          static void main(String[] args) {
              Stream.of("1").forEach({ println(it) })
          }
      }
      

      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:

      public interface D {
          static D of(String s) {
              return new D() {
              };
          }
      }
      
      class C {
          static void main(String[] args) {
              D.of("1")
          }
      }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              marnyl Marcus Nylander
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: