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

Compiler wrongly compiles a ClosureListExpression that results in NoSuchMethodError at runtime

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8-beta-1
    • 1.8-beta-1
    • class generator
    • None

    Description

      r19740 removed the following constructor from CurriedClosure class

      public CurriedClosure(Closure uncurriedClosure, int i) {
          this(uncurriedClosure, new Object[]{Integer.valueOf(i)});
      }
      

      ACG still calls this non-existent constructor in the bytecode it generates for ClosureListExpression and the compiled code results in the following error at runtime

      java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.CurriedClosure.<init>(Lgroovy/lang/Closure;I)V
      

      Here is the test to reproduce it:

      import org.codehaus.groovy.runtime.CurriedClosure
      
      class GroovyXXXXBug extends GroovyTestCase {
          void testClosureListExpressionUsage() {
              def clList = (1;2)
              assert clList[0] instanceof CurriedClosure
              assert clList[1] instanceof CurriedClosure
          }
      }
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: