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

Closure is magically invoked

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.2
    • 1.6.3, 1.7-beta-1
    • Compiler
    • None

    Description

      When the following script is run:

      { -> println "hi" }
      println "bye"
      

      The output is:

      hi
      bye
      

      Even worse is the following:

      foo = 3
      { -> println "hi" }
      

      which results in:

      Caught: groovy.lang.MissingMethodException: 
      No signature of method: java.lang.Integer.call() is applicable for argument types:
      (BindingTest2$_run_closure1) values: [BindingTest2$_run_closure1@144b3c7b]
      groovy.lang.MissingMethodException: 
      No signature of method: java.lang.Integer.call() is applicable for argument types:
      (BindingTest2$_run_closure1) values: [BindingTest2$_run_closure1@144b3c7b]
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at BindingTest2.run(BindingTest2.groovy:1)
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:256)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:218)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:147)
      	at groovy.ui.GroovyMain.processOnce(GroovyMain.java:493)
      	at groovy.ui.GroovyMain.run(GroovyMain.java:308)
      	at groovy.ui.GroovyMain.process(GroovyMain.java:294)
      	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:111)
      	at groovy.ui.GroovyMain.main(GroovyMain.java:92)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
      	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: