Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8959

NPE in StaticVerifier

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.16, 2.5.5
    • Fix Version/s: 2.5.6, 3.0.0-beta-1
    • Component/s: Compiler
    • Labels:
      None

      Description

      I don't have the exact code that created this error, but the fix seems pretty simple.

      // 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);
                                  }
                              }
      
      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
      

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              emilles Eric Milles
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: