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

Compiler wrongly compiles a ClosureListExpression that results in NoSuchMethodError at runtime

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8-beta-1
    • Fix Version/s: 1.8-beta-1
    • Component/s: class generator
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: