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

@Canonical class causes compile-time NPE under @StaticCompilation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1
    • Static compilation
    • None
    • Ubuntu 12.04, Oracle JVM 1.7.0_05-b05

    Description

      import groovy.transform.*
      @CompileStatic
      class CanonicalStaticTest extends GroovyTestCase {
        @Canonical class Thing {
          String stuff
        }
      
        void testCanonical() {
          def thing = new Thing()
        }
      }
      

      fails to compile with the message:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      General error during class generation: NPE while processing CanonicalStaticTest.groovy
      
      groovy.lang.GroovyRuntimeException: NPE while processing CanonicalStaticTest.groovy
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:199)
      	at org.codehaus.groovy.control.CompilationUnit$14.call(CompilationUnit.java:783)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1024)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:562)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:540)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:517)
      	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:283)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:260)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:185)
      	at groovy.lang.GroovyShell$2.run(GroovyShell.java:206)
      	at groovy.lang.GroovyShell$2.run(GroovyShell.java:204)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:204)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:150)
      	at groovy.ui.GroovyMain.processOnce(GroovyMain.java:557)
      	at groovy.ui.GroovyMain.run(GroovyMain.java:344)
      	at groovy.ui.GroovyMain.process(GroovyMain.java:330)
      	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:119)
      	at groovy.ui.GroovyMain.main(GroovyMain.java:99)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	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.classgen.asm.BytecodeHelper.getTypeDescription(BytecodeHelper.java:163)
      	at org.codehaus.groovy.classgen.asm.BytecodeHelper.getTypeDescription(BytecodeHelper.java:126)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitAttributeOrProperty(AsmClassGenerator.java:1013)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitPropertyExpression(AsmClassGenerator.java:1052)
      	at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:55)
      	at org.codehaus.groovy.classgen.asm.InvocationWriter.writeDirectMethodCall(InvocationWriter.java:115)
      	at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.writeDirectMethodCall(StaticInvocationWriter.java:188)
      	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:221)
      	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:76)
      	at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.makeCall(StaticInvocationWriter.java:383)
      	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:60)
      	at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:334)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:649)
      	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:67)
      	at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:604)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:510)
      	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
      	at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:81)
      	at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:49)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:456)
      	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.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:320)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:277)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:397)
      	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1056)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:181)
      	... 25 more
      
      1 error
      

      Attachments

        1. CanonicalStaticTest.groovy
          0.2 kB
          Steven Ruppert

        Activity

          People

            melix Cédric Champeau
            blendmaster Steven Ruppert
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: