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

Calling closure from static method results in IllegalArgumentException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.1-rc-3
    • Fix Version/s: 1.5
    • Component/s: None
    • Labels:
      None

      Description

      The code:

      class Foo {
      
          private static test(tokens) {
              tokens.collect { trimTag(it) }
          }
      
          private static trimTag(pluginVersion) {
              println 'in trim tag'
              int i = pluginVersion.indexOf('-')
              if(i > -1) {
                  pluginVersion = pluginVersion[0,i]
              }
              println 'return version' + pluginVersion
              pluginVersion
          }
      }
      
      
      Foo.test(['1.0', '2.0'])
      

      Results in

      Exception thrown: java.lang.IllegalArgumentException: object is not an instance of declaring class
      
      java.lang.IllegalArgumentException: object is not an instance of declaring class
      	at Foo$_test_closure1.doCall(Script1:4)
      	at Foo.test(Script1:4)
      	at Script1.run(Script1:19)
      

        Attachments

          Activity

            People

            • Assignee:
              ait Alex Tkachman
              Reporter:
              graemerocher Graeme Rocher
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: