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 2015/06/27 02:19:04 UTC

[jira] [Commented] (GROOVY-7477) CompileStatic-related "BUG! exception in phase 'instruction selection'"

    [ https://issues.apache.org/jira/browse/GROOVY-7477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14603826#comment-14603826 ] 

Paul King commented on GROOVY-7477:
-----------------------------------

Seems to be fixed by adding a null guard for {{type}} into {{StaticTypeCheckingSupport#extractGenericsConnections}}
I used this test file:
{code}
import java.util.function.Predicate
List<String> list = ['foo', null, 'bar']
assert list.removeIf({it == null} as Predicate<?>)
println list

@groovy.transform.CompileStatic
void minimalBroken(List list) {
//    list.removeIf({it == null} as Predicate) // already works
//    list.removeIf{it == null}                // already works
    list.removeIf({it == null} as Predicate<?>) // was: BUG! exception in phase 'instruction selection'
    println list
}

minimalBroken([null, 'baz'])
{code}

> CompileStatic-related "BUG! exception in phase 'instruction selection'"
> -----------------------------------------------------------------------
>
>                 Key: GROOVY-7477
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7477
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.3
>         Environment: Groovy Version: 2.4.3 JVM: 1.8.0_45 Vendor: Oracle Corporation OS: Mac OS X
>            Reporter: Joern Huxhorn
>
> Compile the file at [CompilerBug.groovy|http://pastebin.com/23gcFyjs].
> {{groovyc CompilerBug.groovy}}
> h3. Result
> {noformat}
> >>> a serious error occurred: BUG! exception in phase 'instruction selection' in source unit 'CompilerBug.groovy' unexpected NullpointerException
> >>> stacktrace:
> BUG! exception in phase 'instruction selection' in source unit 'CompilerBug.groovy' unexpected NullpointerException
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1057)
> 	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:588)
> 	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:566)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:543)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:522)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:59)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:215)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:148)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:178)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:162)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:497)
> 	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
> 	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
> Caused by: java.lang.NullPointerException
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsConnections(StaticTypeCheckingSupport.java:1601)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsConnections(StaticTypeCheckingSupport.java:1642)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsConnections(StaticTypeCheckingSupport.java:1608)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.inferenceCheck(StaticTypeCheckingSupport.java:1408)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(StaticTypeCheckingSupport.java:1378)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(StaticTypeCheckingSupport.java:1323)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.typeCheckMethodsWithGenericsOrFail(StaticTypeCheckingVisitor.java:4476)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2926)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:294)
> 	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
> 	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:193)
> 	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
> 	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163)
> 	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.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1770)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2103)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2062)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:160)
> 	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1083)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:247)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:119)
> 	at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:60)
> 	at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:132)
> 	at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:176)
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1052)
> 	... 15 more
> {noformat}
> h3. Additional info
> The problem is the {{Predicate<?>}} in combination with {{@CompileStatic}} and {{List<String>}}.
> * If {{@CompileStatic}} is removed, the code compiles fine.
> * If {{[]}} is used instead of {{([] as List<String>)}}, the code compiles fine.
> * If {{Predicate}} is used instead of {{Predicate<?>}}, the code compiles fine.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)