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

Regression with static and non static class mixing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-beta-2, 2.5.16, 3.0.10
    • Compiler
    • None

    Description

      This issue started after the upgrade from 3.0.7 -> 3.0.9

       

      Given the following code:

      class A {
      
           static class B {
               String throwC() {
                   throw new C()
               }
           }
      
           class C extends RuntimeException {
      
           } 
      }

       

      The following exception is thrown. 

      BUG! exception in phase 'semantic analysis' in source unit 'ideaGroovyConsole.groovy' unexpected NullPointerExceptionBUG! exception in phase 'semantic analysis' in source unit 'ideaGroovyConsole.groovy' 
      Caused by: java.lang.NullPointerException at org.codehaus.groovy.classgen.InnerClassVisitor.insertThis0ToSuperCall(InnerClassVisitor.java:304) at org.codehaus.groovy.classgen.InnerClassVisitor.passThisReference(InnerClassVisitor.java:284) at org.codehaus.groovy.classgen.InnerClassVisitor.visitConstructorCallExpression(InnerClassVisitor.java:145) at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:44) at org.codehaus.groovy.ast.CodeVisitorSupport.visitThrowStatement(CodeVisitorSupport.java:179) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitThrowStatement(ClassCodeVisitorSupport.java:236) at org.codehaus.groovy.ast.stmt.ThrowStatement.visit(ThrowStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:164) 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.classgen.InnerClassVisitor.visitConstructorOrMethod(InnerClassVisitor.java:114) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106) 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.InnerClassVisitor.visitClass(InnerClassVisitor.java:84) at org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$4(CompilationUnit.java:214) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:942)

       

      Changing class C to be static causes it to work again

      Attachments

        Activity

          People

            emilles Eric Milles
            Schlogen James Kleeh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: