You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 22:33:00 UTC

[jira] [Closed] (GROOVY-10178) @CompileStatic and @NullCheck make compiler fail

     [ https://issues.apache.org/jira/browse/GROOVY-10178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-10178.
------------------------------

> @CompileStatic and @NullCheck make compiler fail
> ------------------------------------------------
>
>                 Key: GROOVY-10178
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10178
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 3.0.8
>            Reporter: Mauro Ciancio
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.0-beta-2, 3.0.10
>
>         Attachments: 0001-failing-test.patch
>
>
> The following code makes compiler fail with an error:
> {code:java}
> @groovy.transform.CompileStatic
> class A {
>   @groovy.transform.NullCheck
>   void method(String arg) {
>   }
> }
> {code}
>  Compiler shows the following error and exists:
> {code:java}
> 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
> {code}
>  Tested against JDK 11 and JDK8. Both fail with same error.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)