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

Extension methods with closure parameters not found in GroovyShell

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Incomplete
    • 2.1.9, 2.2.1
    • None
    • groovy-runtime
    • None
    • JDK 7 Win32, IntelliJ IDEA 13 Community

    Description

      When implementing an extension (registered via META-INF/services ...) I've created this function signature in the extension class:

      static JCO.Table eachRow(JCO.Table table, Closure closure)

      In client code IDEA 13 in all its brilliance even brings up this method in code completion on an object known to be of type JCO.Table. It looks exactly like any method from DefaultGroovyMethods. The extension itself is written in Groovy with @CompileStatic.

      The line is:

      dattab.eachRow { println it.WA }
      

      Upon execution it causes this exception:

      groovy.lang.MissingMethodException: No signature of method: com.sap.mw.jco.JCO$Table.eachRow() is applicable for argument types: (ReadTable$_run_closure1) values: [ReadTable$_run_closure1@191c88c]
      Possible solutions: eachRow(groovy.lang.Closure), lastRow(), each(groovy.lang.Closure), getRow(), nextRow(), setRow(int)
      

      Other extension methods on JCO.Table and its parent class JCO.Record work fine.

      The eachRow(groovy.lang.Closure) from the extension even shows up in the exception text. But the closure in the Groovy script is not matched to this parameter.

      Update:
      The problem does not pop up when running the compilied Groovy code.
      It also does not pop up when running the script in a GroovyScriptEngine. Fortunately our real life applications all use GroovyScriptEngine.

      This might a a problem with IDEA's way of running a script via the IDE button for that purpose. From the stack strace it is apparent that GroovyShell is used:

      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      	at ReadTable.run(ReadTable.groovy:36)
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:257)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:220)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:150)
      	at groovy.ui.GroovyMain.processOnce(GroovyMain.java:588)
      	at groovy.ui.GroovyMain.run(GroovyMain.java:375)
      	at groovy.ui.GroovyMain.process(GroovyMain.java:361)
      	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:120)
      	at groovy.ui.GroovyMain.main(GroovyMain.java:100)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
      	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              eddelplus Jochen Eddelbuettel
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: