Details
Description
Try compiling the following code using Groovy 3.0.9:
import groovy.transform.CompileDynamic import groovy.transform.CompileStatic @CompileStatic class MyConstructorBug { @CompileDynamic MyConstructorBug() { StringReader reader = new StringReader("abc") } }
It'll fail with the following exception:
java.lang.ArrayIndexOutOfBoundsException: size==0 at org.codehaus.groovy.classgen.asm.OperandStack.ensureStackNotEmpty(OperandStack.java:279) at org.codehaus.groovy.classgen.asm.OperandStack.getTopOperand(OperandStack.java:646) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:400) at org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:202) at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:702) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89) at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:635) at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:687) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:94) at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:78) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:618) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:138) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:111) at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:462) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:409) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:101) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructor(AsmClassGenerator.java:551) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1089) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:272) at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:797) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:942) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:610)
Attachments
Issue Links
- is related to
-
GROOVY-10458 Path to a problematic file isn't shown in the error message sometimes if compilation fails with IndexOutOfBoundsException
- Closed
-
GROOVY-10459 Compilation of code which access array element inside CompileDynamic constructor fails
- Closed
- relates to
-
GROOVY-10459 Compilation of code which access array element inside CompileDynamic constructor fails
- Closed