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

Problem dispatching array as argument to a closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.2
    • 2.1.0-rc-1, 1.8.9, 2.0.7
    • None
    • None

    Description

      myscript.groovy
      ExpandoMetaClass.enableGlobally()
      
      Object[] myObjectArray = ['a', 'b'] as Object[]
      
      closure = {
      	println 'closure running...'
      }
      	
      closure(myObjectArray)
      
      code $ groovy -version
      Groovy Version: 1.8.2 JVM: 1.6.0_26
      code $ groovy myscript.groovy 
      Caught: groovy.lang.MissingMethodException: No signature of method: myscript$_run_closure1.doCall() is applicable for argument types: (java.lang.String, java.lang.String) values: [a, b]
      Possible solutions: doCall(), doCall(java.lang.Object), call(), call([Ljava.lang.Object;), call(java.lang.Object), findAll()
      groovy.lang.MissingMethodException: No signature of method: myscript$_run_closure1.doCall() is applicable for argument types: (java.lang.String, java.lang.String) values: [a, b]
      Possible solutions: doCall(), doCall(java.lang.Object), call(), call([Ljava.lang.Object;), call(java.lang.Object), findAll()
      	at myscript.run(myscript.groovy:9)
      

      I have tested with versions all the way back to 1.7.0 and the exception is thrown for all the versions I tested.

      If I remove the ExpandoMetaClass.enableGlobally(), the exception goes away.

      I think this is related to http://jira.grails.org/browse/GRAILS-8002, though I am not sure why that problem just showed up in Grails 2.0-M2. I have not been able to reproduce it with Grails 1.3.7.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            brownj Jeff Brown
            Votes:
            9 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: