groovy
  1. groovy
  2. GROOVY-4254

Compiler wrongly compiles a ClosureListExpression that results in NoSuchMethodError at runtime

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8-beta-1
    • Fix Version/s: 1.8-beta-1
    • Component/s: class generator
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      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
          }
      }
      

        Activity

        Hide
        Roshan Dawrani added a comment -

        Fixed.

        Show
        Roshan Dawrani added a comment - Fixed.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: