You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "John Flinchbaugh (JIRA)" <ji...@apache.org> on 2015/07/02 00:23:04 UTC
[jira] [Updated] (GROOVY-7485) BUG! exception in phase 'semantic
analysis'... when trying to call instance method as default for a
constructor parameter
[ https://issues.apache.org/jira/browse/GROOVY-7485?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Flinchbaugh updated GROOVY-7485:
-------------------------------------
Description:
% groovyc StaticDefault.groovy # the code below
{code}
class StaticDefault {
def name
StaticDefault(name = getName()) {
this.name = name
}
private getName() {
'name'
}
}
{code}
And see this stacktrace:
{code}
>>> a serious error occurred: BUG! exception in phase 'semantic analysis' in source unit 'StaticDefault.groovy' unexpected NullpointerException
>>> stacktrace:
BUG! exception in phase 'semantic analysis' in source unit 'StaticDefault.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:483)
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.control.StaticVerifier$1.visitVariableExpression(StaticVerifier.java:84)
at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:70)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodCallExpression(CodeVisitorSupport.java:129)
at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
at org.codehaus.groovy.control.StaticVerifier.visitConstructorOrMethod(StaticVerifier.java:79)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:119)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1079)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:42)
at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:209)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1052)
... 15 more
{code}
Switching the method used for the default to a static method fixes the problem, but I'm guessing you likely wanted to give a better message out of the compiler.
was:
% groovyc StaticDefault.groovy # the code below
{code}
class StaticDefault {
def name
StaticDefault(name = getName()) {
this.name = name
}
private getName() {
'name'
}
}
{code}
And see a big the stacktrace:
{code}
>>> a serious error occurred: BUG! exception in phase 'semantic analysis' in source unit 'StaticDefault.groovy' unexpected NullpointerException
>>> stacktrace:
BUG! exception in phase 'semantic analysis' in source unit 'StaticDefault.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:483)
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.control.StaticVerifier$1.visitVariableExpression(StaticVerifier.java:84)
at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:70)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodCallExpression(CodeVisitorSupport.java:129)
at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
at org.codehaus.groovy.control.StaticVerifier.visitConstructorOrMethod(StaticVerifier.java:79)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:119)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1079)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:42)
at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:209)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1052)
... 15 more
{code}
Switching the method used for the default to a static method fixes the problem, but I'm guessing you likely wanted to give a better message out of the compiler.
> BUG! exception in phase 'semantic analysis'... when trying to call instance method as default for a constructor parameter
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-7485
> URL: https://issues.apache.org/jira/browse/GROOVY-7485
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 2.4.3
> Environment: Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
> Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
> Seen in java 7 too.
> Reporter: John Flinchbaugh
> Priority: Minor
>
> % groovyc StaticDefault.groovy # the code below
> {code}
> class StaticDefault {
> def name
> StaticDefault(name = getName()) {
> this.name = name
> }
> private getName() {
> 'name'
> }
> }
> {code}
> And see this stacktrace:
> {code}
> >>> a serious error occurred: BUG! exception in phase 'semantic analysis' in source unit 'StaticDefault.groovy' unexpected NullpointerException
> >>> stacktrace:
> BUG! exception in phase 'semantic analysis' in source unit 'StaticDefault.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:483)
> 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.control.StaticVerifier$1.visitVariableExpression(StaticVerifier.java:84)
> at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:70)
> at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodCallExpression(CodeVisitorSupport.java:129)
> at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
> at org.codehaus.groovy.control.StaticVerifier.visitConstructorOrMethod(StaticVerifier.java:79)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:119)
> at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1079)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
> at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:42)
> at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:209)
> at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1052)
> ... 15 more
> {code}
> Switching the method used for the default to a static method fixes the problem, but I'm guessing you likely wanted to give a better message out of the compiler.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)