groovy
  1. groovy
  2. GROOVY-5386

@Delegate - sometimes compilation fails for generic types

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0-beta-2, 1.8.6
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      JVM: 1.6.0_29 Vendor: Apple Inc. OS: Mac OS X
    • Number of attachments :
      0

      Description

      we have some classes using @Delegate on generic classes:

      @Commons
      class FilterList

      { @Delegate List<Map<Dimension, List<String>>> filterList = [] ... }

      Sometime compilation fails with compiler errors like

      BUG! exception in phase 'class generation' in source unit '/Users/andre/Development/Projects/Adternity/grf/grails-app/jobs/com/grf/reports/ScheduledReportExecutionJob.groovy' Type is null. Most probably you let a transform reuse existing ClassNodes with generics information, that is now used in a wrong context. (Use --stacktrace to see the full trace)

      I assume this has to do with DelegateASTTransformation#nonGeneric handling of generic types, which is setting the generic type to null, but it's hard to reproduce the error in a determined way.

        Activity

        Hide
        Andre Steingress added a comment -

        I've just seen that DelegateASTTransformation uses a new ClassNode instance, so the compiler error above shouldn't come from that place, am I right?

        Show
        Andre Steingress added a comment - I've just seen that DelegateASTTransformation uses a new ClassNode instance, so the compiler error above shouldn't come from that place, am I right?
        Hide
        CÚdric Champeau added a comment -

        What is the @Commons annotation? Is it an AST xform too?

        Show
        CÚdric Champeau added a comment - What is the @Commons annotation? Is it an AST xform too?
        Show
        Andre Steingress added a comment - Yep, http://groovy.codehaus.org/api/groovy/util/logging/Commons.html
        Hide
        Andre Steingress added a comment - - edited

        I did a simple lookup to find all the usages of setGenericTypes in groovy-core. The only two ast xforms directly calling this method are:

        DelegateASTTransformation
        ListenerListASTTransformation

        Hm, I think the error above did not occur before introducing @Delegate - but of course I could be wrong and it is caused by some Grails xform.

        Show
        Andre Steingress added a comment - - edited I did a simple lookup to find all the usages of setGenericTypes in groovy-core. The only two ast xforms directly calling this method are: DelegateASTTransformation ListenerListASTTransformation Hm, I think the error above did not occur before introducing @Delegate - but of course I could be wrong and it is caused by some Grails xform.
        Hide
        CÚdric Champeau added a comment -

        Does it happen in a plain Groovy project too? Grails also performs transparent AST transformations which could be in action here.

        Show
        CÚdric Champeau added a comment - Does it happen in a plain Groovy project too? Grails also performs transparent AST transformations which could be in action here.
        Hide
        Andre Steingress added a comment -

        I'll try to reproduce it in a standalone Groovy project as we're running into this issue now regularly, which is pain because the programmer (including me ) needs to clean and recompile the Grails project.

        
        | Packaging Grails application
        | Packaging Grails application.
        | Packaging Grails application..
        | Packaging Grails application...
        | Packaging Grails application....
        | Packaging Grails application.....
        | Compiling 11 source files
        | Compiling 11 source files.
        | Error Fatal error during compilation org.apache.tools.ant.BuildException: BUG! exception in phase 'class generation' in source unit '/super/secret/XXX.groovy' Type is null. Most probably you let a transform reuse existing ClassNodes with generics information, that is now used in a wrong context. (Use --stacktrace to see the full trace)
        
        Show
        Andre Steingress added a comment - I'll try to reproduce it in a standalone Groovy project as we're running into this issue now regularly, which is pain because the programmer (including me ) needs to clean and recompile the Grails project. | Packaging Grails application | Packaging Grails application. | Packaging Grails application.. | Packaging Grails application... | Packaging Grails application.... | Packaging Grails application..... | Compiling 11 source files | Compiling 11 source files. | Error Fatal error during compilation org.apache.tools.ant.BuildException: BUG! exception in phase 'class generation' in source unit '/ super /secret/XXX.groovy' Type is null . Most probably you let a transform reuse existing ClassNodes with generics information, that is now used in a wrong context. (Use --stacktrace to see the full trace)
        Hide
        Andre Steingress added a comment - - edited

        It seems to me that this issue occurs when recompiling classes with a reference to already compiled @Delegate classes. But as I've said before, I'll try to reproduce it...

        Show
        Andre Steingress added a comment - - edited It seems to me that this issue occurs when recompiling classes with a reference to already compiled @Delegate classes. But as I've said before, I'll try to reproduce it...
        Hide
        Andre Steingress added a comment - - edited

        Here is the full stracktrace, just for the record:

        	at org.codehaus.groovy.vmplugin.v5.Java5.configureType(Java5.java:96)
        	at org.codehaus.groovy.vmplugin.v5.Java5.configureTypeArguments(Java5.java:157)
        	at org.codehaus.groovy.vmplugin.v5.Java5.configureParameterizedType(Java5.java:137)
        	at org.codehaus.groovy.vmplugin.v5.Java5.configureType(Java5.java:88)
        	at org.codehaus.groovy.vmplugin.v5.Java5.makeClassNode(Java5.java:384)
        	at org.codehaus.groovy.vmplugin.v5.Java5.makeInterfaceTypes(Java5.java:365)
        	at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:348)
        	at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:262)
        	at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:974)
        	at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:969)
        	at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:963)
        	at org.codehaus.groovy.ast.ClassNode.getPlainNodeReference(ClassNode.java:1369)
        	at org.codehaus.groovy.classgen.asm.ClosureWriter.createClosureClass(ClosureWriter.java:262)
        	at org.codehaus.groovy.classgen.asm.ClosureWriter.getOrAddClosureClass(ClosureWriter.java:144)
        	at org.codehaus.groovy.classgen.asm.ClosureWriter.writeClosure(ClosureWriter.java:71)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClosureExpression(AsmClassGenerator.java:540)
        	at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:43)
        	at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:301)
        	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:187)
        	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:89)
        	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:73)
        	at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:292)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:657)
        	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:75)
        	at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:599)
        	at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:354)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:503)
        	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
        	at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:80)
        	at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:449)
        	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
        	at org.codehaus.groovy.classgen.asm.StatementWriter.writeTryCatchFinally(StatementWriter.java:315)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitTryCatchFinally(AsmClassGenerator.java:473)
        	at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:42)
        	at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:80)
        	at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:449)
        	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:313)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:270)
        	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
        	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:390)
        	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:174)
        	at org.codehaus.groovy.control.CompilationUnit$14.call(CompilationUnit.java:767)
        	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:967)
        	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:546)
        	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:524)
        	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:501)
        	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:480)
        	at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:60)
        	at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:216)
        	at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:909)
        
        Show
        Andre Steingress added a comment - - edited Here is the full stracktrace, just for the record: at org.codehaus.groovy.vmplugin.v5.Java5.configureType(Java5.java:96) at org.codehaus.groovy.vmplugin.v5.Java5.configureTypeArguments(Java5.java:157) at org.codehaus.groovy.vmplugin.v5.Java5.configureParameterizedType(Java5.java:137) at org.codehaus.groovy.vmplugin.v5.Java5.configureType(Java5.java:88) at org.codehaus.groovy.vmplugin.v5.Java5.makeClassNode(Java5.java:384) at org.codehaus.groovy.vmplugin.v5.Java5.makeInterfaceTypes(Java5.java:365) at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:348) at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:262) at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:974) at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:969) at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:963) at org.codehaus.groovy.ast.ClassNode.getPlainNodeReference(ClassNode.java:1369) at org.codehaus.groovy.classgen.asm.ClosureWriter.createClosureClass(ClosureWriter.java:262) at org.codehaus.groovy.classgen.asm.ClosureWriter.getOrAddClosureClass(ClosureWriter.java:144) at org.codehaus.groovy.classgen.asm.ClosureWriter.writeClosure(ClosureWriter.java:71) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClosureExpression(AsmClassGenerator.java:540) at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:43) at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:301) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:187) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:89) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:73) at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:292) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:657) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:75) at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:599) at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:354) at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:503) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:80) at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:449) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at org.codehaus.groovy.classgen.asm.StatementWriter.writeTryCatchFinally(StatementWriter.java:315) at org.codehaus.groovy.classgen.AsmClassGenerator.visitTryCatchFinally(AsmClassGenerator.java:473) at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:42) at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:80) at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:449) 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:313) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:270) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:390) 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:174) at org.codehaus.groovy.control.CompilationUnit$14.call(CompilationUnit.java:767) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:967) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:546) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:524) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:501) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:480) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:60) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:216) at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:909)

          People

          • Assignee:
            Unassigned
            Reporter:
            Andre Steingress
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: