Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.8
-
None
Description
The following code makes compiler fail with an error:
@groovy.transform.CompileStatic class A { @groovy.transform.NullCheck void method(String arg) { } }
Compiler shows the following error and exists:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during instruction selection: Index -1 out of bounds for length 0 java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) at java.base/java.util.Objects.checkIndex(Objects.java:372) at java.base/java.util.ArrayList.remove(ArrayList.java:535) at org.codehaus.groovy.classgen.asm.OperandStack.popWithMessage(OperandStack.java:110) at org.codehaus.groovy.classgen.asm.OperandStack.remove(OperandStack.java:218) at org.codehaus.groovy.classgen.asm.StatementWriter.writeThrow(StatementWriter.java:592) at org.codehaus.groovy.classgen.AsmClassGenerator.visitThrowStatement(AsmClassGenerator.java:676) at org.codehaus.groovy.ast.stmt.ThrowStatement.visit(ThrowStatement.java:41) at org.codehaus.groovy.classgen.asm.StatementWriter.writeIfElse(StatementWriter.java:323) at org.codehaus.groovy.classgen.AsmClassGenerator.visitIfElse(AsmClassGenerator.java:637) at org.codehaus.groovy.ast.stmt.IfStatement.visit(IfStatement.java:41) 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:617) 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:461) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:408) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:556) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1099) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1092) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:271) 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) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:111) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:129) 1 error
Tested against JDK 11 and JDK8. Both fail with same error.