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

vmplugin throws NPE when trying to throw a GroovyBugException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.5
    • 1.8-rc-4, 1.7.11
    • class generator
    • None
    • Ubuntu 10.10, Grails 1.3.6, IntelliJ Idea 10

    Description

      When running unit tests in IntelliJ I regularly get the following stacktrace:

      java.lang.NullPointerException
      	at org.codehaus.groovy.vmplugin.v5.Java5.configureType(Java5.java:95)
      	at org.codehaus.groovy.vmplugin.v5.Java5.makeClassNode(Java5.java:374)
      	at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:320)
      	at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:263)
      	at org.codehaus.groovy.ast.ClassNode.getInterfaces(ClassNode.java:341)
      	at org.codehaus.groovy.ast.ClassNode.declaresInterface(ClassNode.java:929)
      	at org.codehaus.groovy.ast.ClassNode.implementsInterface(ClassNode.java:909)
      	at org.codehaus.groovy.ast.ClassNode.isDerivedFromGroovyObject(ClassNode.java:899)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.isGroovyObject(AsmClassGenerator.java:2741)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitPropertyExpression(AsmClassGenerator.java:2717)
      	at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:55)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4111)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.makeCallSite(AsmClassGenerator.java:2175)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.makeCall(AsmClassGenerator.java:2012)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.makeCall(AsmClassGenerator.java:1998)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.makeInvokeMethodCall(AsmClassGenerator.java:1981)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:2335)
      	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:72)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4111)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:1458)
      	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:165)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:729)
      	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51)
      	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:616)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:591)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:686)
      	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1039)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:276)
      	at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:738)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:932)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:509)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)
      	at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:43)
      	at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:128)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:75)
      

      This has already been reported to JetBrains IntelliJ team, as I think the initial bug is theirs, however, there should not be a NullPointerException here, but a GroovyBugException because it can't find the correct type.

      The block of code looks like this:

         83       private ClassNode configureType(Type type) {
         84           if (type instanceof WildcardType) {
         85               return configureWildcardType((WildcardType) type);
         86           } else if (type instanceof ParameterizedType) {
         87               return configureParameterizedType((ParameterizedType) type);
         88           } else if (type instanceof GenericArrayType) {
         89               return configureGenericArray((GenericArrayType) type);
         90           } else if (type instanceof TypeVariable) {
         91               return configureTypeVariableReference((TypeVariable) type);
         92           } else if (type instanceof Class) {
         93               return configureClass((Class) type);
         94           } else {
         95               throw new GroovyBugError("unknown type: " + type + " := " + type.getClass());
         96           }
         97       }
      

      on line 95 - I believe that type.getClass() is being called when 'type' is null, hence the NPE.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            wirah Antony Jones
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: