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

groovy compiler throws ArrayIndexOutOfBoundsException when combining @CompileStatic with @ToString/@EqualsAndHashCode with certain property names

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.4
    • 2.1.8, 2.2.0
    • Static compilation
    • None
    • Windows 7, Java 6, Groovy 2.1.4

    Description

      It seems to occur when a property in the object has a name where the 2nd character is uppercase. It happens with both @ToString and @EqualsAndHashCode. Example:

      @groovy.transform.CompileStatic
      @groovy.transform.ToString
      class MyClass {
          List<String> aList
      }
      


      Groovyc: java.lang.ArrayIndexOutOfBoundsException: Internal compiler error while compiling C:\myProject\src\MyClass.groovy
      Method: MethodNode@781552568[java.lang.String toString()]
      Line -1, expecting casting to java.lang.Object but operand stack is empty
      at org.codehaus.groovy.classgen.asm.OperandStack.doConvertAndCast(OperandStack.java:327)
      at org.codehaus.groovy.classgen.asm.OperandStack.doGroovyCast(OperandStack.java:294)
      at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.loadArguments(StaticInvocationWriter.java:271)
      at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.writeDirectMethodCall(StaticInvocationWriter.java:136)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeDirectCall(InvocationWriter.java:228)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:326)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:76)
      at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.makeCall(StaticInvocationWriter.java:445)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:60)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:382)
      at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.writeInvokeMethod(StaticInvocationWriter.java:90)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:650)
      at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
      at org.codehaus.groovy.transform.sc.transformers.BooleanExpressionTransformer$OptimizingBooleanExpression.visit(BooleanExpressionTransformer.java:95)
      at org.codehaus.groovy.classgen.asm.StatementWriter.writeIfElse(StatementWriter.java:279)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitIfElse(AsmClassGenerator.java:473)
      at org.codehaus.groovy.ast.stmt.IfStatement.visit(IfStatement.java:41)
      at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:81)
      at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:49)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:457)
      at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
      at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:81)
      at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:49)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:457)
      at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:321)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:278)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:398)
      at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1055)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:180)
      at org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:794)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1036)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:572)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            bborchardt Brett Borchardt
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: