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 2019/02/21 06:19:02 UTC

[jira] [Closed] (GROOVY-8959) NPE in StaticVerifier

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

Paul King closed GROOVY-8959.
-----------------------------

> NPE in StaticVerifier
> ---------------------
>
>                 Key: GROOVY-8959
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8959
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.16, 2.5.5
>            Reporter: Eric Milles
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 2.5.6, 3.0.0-alpha-5
>
>
> I don't have the exact code that created this error, but the fix seems pretty simple.
> {code:java}
> // excerpt from StaticVerifier.visitConstructorOrMethod
>                         public void visitVariableExpression(VariableExpression ve) {
>                             if (exceptions.contains(ve.getName())) return;
>                             /* GRECLIPSE edit -- VariableExpression.isInStaticContext is null safe
>                             Variable av = ve.getAccessedVariable();
>                             if (av instanceof DynamicVariable || !av.isInStaticContext()) { // this is line 96
>                             */
>                             if (ve.getAccessedVariable() instanceof DynamicVariable || !ve.isInStaticContext()) {
>                             // GRECLIPSE end
>                                 addVariableError(ve);
>                             }
>                         }
> {code}
> {code}
> java.lang.NullPointerException
> 	at org.codehaus.groovy.control.StaticVerifier$1.visitVariableExpression(StaticVerifier.java:96)
> 	at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:72)
> 	at org.codehaus.groovy.ast.CodeVisitorSupport.visitPropertyExpression(CodeVisitorSupport.java:302)
> 	at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:57)
> 	at org.codehaus.groovy.control.StaticVerifier.visitConstructorOrMethod(StaticVerifier.java:91)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:162)
> 	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1210)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54)
> 	at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:54)
> 	at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:241)
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1143)
> 	... 20 more
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)