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

Calling closure from static method results in IllegalArgumentException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.1-rc-3
    • 1.5
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: