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

MissingMethodException for java Function<>

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 3.0.18, 3.0.19, 3.0.20
    • None
    • None
    • None
    • openjdk version "11.0.21" 2023-10-17
      OpenJDK Runtime Environment Temurin-11.0.21+9 (build 11.0.21+9)
      OpenJDK 64-Bit Server VM Temurin-11.0.21+9 (build 11.0.21+9, mixed mode)

    Description

      Hello,

      the code fails with the Exception on java 11.0.21 on groovy 3.0.18.

      It works fine on groovy 3.0.17 or lower

      import java.util.function.Function
      
      class A {
          int a
      }
      
      class ToothChartContainerExtractionComparator implements Comparator<A> {
      
          @Override
          int compare(A a, A b) {
              comparing(typePriorityKeyExtractor).compare(a, b)
          }
      
          private static Function<A, Integer> typePriorityKeyExtractor = {it.a } as Function<A, Integer>
      
      }
      
      new ToothChartContainerExtractionComparator().compare(new A(), new A()) 
      groovy.lang.MissingMethodException: No signature of method: ToothChartContainerExtractionComparator.comparing() is applicable for argument types: (com.sun.proxy.$Proxy18) values: [ToothChartContainerExtractionComparator$__clinit__closure1@75181b50] Possible solutions: toString(), toString(), compare(A, A), compare(java.lang.Object, java.lang.Object)     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)     at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:80)     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)     at ToothChartContainerExtractionComparator.compare(ideaGroovyConsole.groovy:11)     at ToothChartContainerExtractionComparator$compare.call(Unknown Source)     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)     at ideaGroovyConsole.run(ideaGroovyConsole.groovy:18)     at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:254)     at groovy.lang.GroovyShell.run(GroovyShell.java:360)     at groovy.lang.GroovyShell.run(GroovyShell.java:339)     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:566)     at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:48)     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:166)     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:69)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)     at console.run(console.groovy:11)     at groovy.ui.GroovyMain.processReader(GroovyMain.java:631)     at groovy.ui.GroovyMain.processFiles(GroovyMain.java:552)     at groovy.ui.GroovyMain.run(GroovyMain.java:396)     at groovy.ui.GroovyMain.access$1400(GroovyMain.java:68)     at groovy.ui.GroovyMain$GroovyCommand.process(GroovyMain.java:322)     at groovy.ui.GroovyMain.processArgs(GroovyMain.java:142)     at groovy.ui.GroovyMain.main(GroovyMain.java:115)     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:566)     at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:117)     at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:39)
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              agre1981 Alex
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: