groovy
  1. groovy
  2. GROOVY-5009

Problem dispatching array as argument to a closure

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.2
    • Fix Version/s: 2.1.0-rc-1, 1.8.9, 2.0.7
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      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.

        Activity

        Hide
        Jeff Scott Brown added a comment -
        ~ $ groovy -version
        Groovy Version: 1.8.8 JVM: 1.6.0_37 Vendor: Apple Inc. OS: Mac OS X
        ~ $ 
        ~ $ cat doit.groovy 
        ExpandoMetaClass.enableGlobally()
        
        Object[] myObjectArray = ['a', 'b'] as Object[]
        
        closure = {
            println 'closure running...'
        }
        
        closure(myObjectArray)
        
        ~ $ 
        ~ $ groovy doit.groovy 
        Caught: groovy.lang.MissingMethodException: No signature of method: doit$_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: doit$_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 doit.run(doit.groovy:9)
        ~ $ 
        
        Show
        Jeff Scott Brown added a comment - ~ $ groovy -version Groovy Version: 1.8.8 JVM: 1.6.0_37 Vendor: Apple Inc. OS: Mac OS X ~ $ ~ $ cat doit.groovy ExpandoMetaClass.enableGlobally() Object[] myObjectArray = ['a', 'b'] as Object[] closure = { println 'closure running...' } closure(myObjectArray) ~ $ ~ $ groovy doit.groovy Caught: groovy.lang.MissingMethodException: No signature of method: doit$_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: doit$_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 doit.run(doit.groovy:9) ~ $
        Hide
        blackdrag blackdrag added a comment -

        reopen for now till I verified it is really fixed in 1.8.9

        Show
        blackdrag blackdrag added a comment - reopen for now till I verified it is really fixed in 1.8.9
        Hide
        Jeff Scott Brown added a comment -

        Should we remove 1.8.3 from the "Fix Version" field?

        Show
        Jeff Scott Brown added a comment - Should we remove 1.8.3 from the "Fix Version" field?
        Hide
        blackdrag blackdrag added a comment -

        looks like I made a fix, but then did not apply it to 2.0.x and 1.8.x

        Show
        blackdrag blackdrag added a comment - looks like I made a fix, but then did not apply it to 2.0.x and 1.8.x
        Hide
        blackdrag blackdrag added a comment -

        I found the fix I did back then and that it is indeed in master and 2.1.0-RC-x, but is missing on 1.8.x and 2.0.x. So I pushed the change there as well and close the issue with that

        Show
        blackdrag blackdrag added a comment - I found the fix I did back then and that it is indeed in master and 2.1.0-RC-x, but is missing on 1.8.x and 2.0.x. So I pushed the change there as well and close the issue with that

          People

          • Assignee:
            blackdrag blackdrag
            Reporter:
            Jeff Scott Brown
          • Votes:
            9 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: