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

Error caused by @CompileStatic

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.0
    • Fix Version/s: 2.4.1
    • Component/s: Static compilation
    • Labels:
      None

      Description

      In the ratpack team, we recently upgraded from Groovy 2.3.6 to Groovy 2.4.0. After the upgrade, we've identified a couple applications that had previously been working that now fail at runtime. In both cases, removing @CompileStatic from a Guice module appears to work around the problem.

      In one case (private application, source cannot be shared), the resulting exception was:

      java.lang.NullPointerException
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:203)
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:218)
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:169)
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:218)
          at com.sun.beans.TypeResolver.resolveInClass(TypeResolver.java:96)
          at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
          at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116)
          at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
          at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
          at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1163)
          at java.beans.Introspector.getBeanInfo(Introspector.java:426)
          at java.beans.Introspector.getBeanInfo(Introspector.java:173)
          at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3290)
          at java.security.AccessController.doPrivileged(Native Method)
          at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3288)
          at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3264)
          at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:251)
          at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:282)
          at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:255)
          at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:872)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:84)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:230)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:234)
      ...
      

      In the other case, (https://github.com/ratpack/example-ratpack-gradle-groovy-app/tree/latest) the exception is:

      BUG! exception in phase 'instruction selection' in source unit 'Ratpack.groovy' Type is null. Most probably you let a transform reuse existing ClassNodes with generics information, that is now used in a wrong context.
          at org.codehaus.groovy.vmplugin.v5.Java5.configureType(Java5.java:122)
          at org.codehaus.groovy.vmplugin.v5.Java5.configureTypeArguments(Java5.java:183)
          at org.codehaus.groovy.vmplugin.v5.Java5.configureParameterizedType(Java5.java:163)
          at org.codehaus.groovy.vmplugin.v5.Java5.configureType(Java5.java:114)
          at org.codehaus.groovy.vmplugin.v5.Java5.makeClassNode(Java5.java:429)
          at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:362)
          at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:262)
          at org.codehaus.groovy.ast.ClassNode.getDeclaredConstructors(ClassNode.java:483)
          at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.findMethod(StaticTypeCheckingVisitor.java:3695)
          at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.findMethodOrFail(StaticTypeCheckingVisitor.java:3547)
          at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.findMethodOrFail(StaticCompilationVisitor.java:316)
          at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorCallExpression(StaticTypeCheckingVisitor.java:1848)
          at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitConstructorCallExpression(StaticCompilationVisitor.java:278)
          at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:44)
          at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2246)
          at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2731)
          at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:262)
          at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
          at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)
          at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:193)
          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:163)
          at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
          at org.codehaus.groovy.ast.CodeVisitorSupport.visitClosureExpression(CodeVisitorSupport.java:174)
      

      To reproduce this result:

      • comment out the line for the springloaded dependency in build.gradle
      • run ./gradlew run
      • Open a browser to http://localhost:5050
      • Check the console for the stacktrace

      While this appears to be a similar problem to GROOVY-7264, testing 2.4.1-SNAPSHOT and 2.5.0-SNAPSHOT seem to still have the problem.

      Based on testing with "git bisect", it appears that the problem was first introduced in commit cd4a75c21ed44ada2b741bd822c1be5b8f4801b9 (GROOVY-7063: IllegalAccessError when calling a protected method from a closure in a sub-class).

        Attachments

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              david@carr.name David Carr
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: