ajwang / groovypptest

Automatically exported from code.google.com/p/groovypptest
0 stars 0 forks source link

@Log and @Slf4j annotations cause errors #379

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
using the @Slf4j Annotation in a groovy 1.8 script which works fine, however if 
I rename to .gpp (or annotate appropriately) to use Groovy++ it fails with the 
following error...

    > groovy -cp logback-classic-0.9.28.jar:logback-core-0.9.28.jar:slf4j-api-1.6.1.jar test_log.gpp
    BUG! ClassNode#getTypeClass for org.slf4j.Logger is called before the type class is set
            at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1311)
            at org.mbte.groovypp.compiler.ClassNodeCache.getClassNodeInfo(ClassNodeCache.java:181)
            at org.mbte.groovypp.compiler.ClassNodeCache.getMethods(ClassNodeCache.java:238)
            at org.mbte.groovypp.compiler.CompilerTransformer.findMethod(CompilerTransformer.java:256)
            at org.mbte.groovypp.compiler.transformers.MethodCallExpressionTransformer.findMethodVariatingArgs(MethodCallExpressionTransformer.java:610)
            at org.mbte.groovypp.compiler.transformers.MethodCallExpressionTransformer.findMethodWithClosureCoercion(MethodCallExpressionTransformer.java:832)
            at org.mbte.groovypp.compiler.transformers.MethodCallExpressionTransformer.createNormalMethodCall(MethodCallExpressionTransformer.java:113)
            at org.mbte.groovypp.compiler.transformers.MethodCallExpressionTransformer.transform(MethodCallExpressionTransformer.java:92)
            at org.mbte.groovypp.compiler.transformers.MethodCallExpressionTransformer.transform(MethodCallExpressionTransformer.java:36)
            at org.mbte.groovypp.compiler.transformers.ExprTransformer.transformExpression(ExprTransformer.groovy:103)
            at org.mbte.groovypp.compiler.CompilerTransformer.transform(CompilerTransformer.java:114)
            at org.mbte.groovypp.compiler.CompilerTransformer.transformToGround(CompilerTransformer.java:132)
            at org.mbte.groovypp.compiler.StaticCompiler.visitReturnStatement(StaticCompiler.java:732)
            at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
            at org.mbte.groovypp.compiler.StaticCompiler.visitBlockStatement(StaticCompiler.java:378)
            at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
            at org.mbte.groovypp.compiler.StaticCompiler.execute(StaticCompiler.java:1232)
            at org.mbte.groovypp.compiler.StaticMethodBytecode.<init>(StaticMethodBytecode.java:71)
            at org.mbte.groovypp.compiler.StaticMethodBytecode.replaceMethodCode(StaticMethodBytecode.java:95)
            at org.mbte.groovypp.compiler.CompileASTTransform.visit(CompileASTTransform.java:121)
            at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:129)
            at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:172)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:957)
            at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:542)
            at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:520)
            at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497)
            at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
            at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:283)
            at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:267)
            at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:197)
            at groovy.lang.GroovyShell$2.run(GroovyShell.java:215)
            at groovy.lang.GroovyShell$2.run(GroovyShell.java:213)
            at java.security.AccessController.doPrivileged(Native Method)
            at groovy.lang.GroovyShell.run(GroovyShell.java:213)
            at groovy.lang.GroovyShell.run(GroovyShell.java:159)
            at groovy.ui.GroovyMain.processOnce(GroovyMain.java:514)
            at groovy.ui.GroovyMain.run(GroovyMain.java:329)
            at groovy.ui.GroovyMain.process(GroovyMain.java:315)
            at groovy.ui.GroovyMain.processArgs(GroovyMain.java:112)
            at groovy.ui.GroovyMain.main(GroovyMain.java:93)
            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 org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
            at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
    /home/morris/work/groovy/test_log.gpp: 7: BUG! ClassNode#getTypeClass for org.slf4j.Logger is called before the type class is set
     @ line 7, column 3.
                    log.info("I'm in the logger")
         ^

    1 error

The script is the bare minimum to demonstrate this bug... test.gpp

    import groovy.util.logging.Slf4j

    @Slf4j
    public class TestLog {

        public void doLog() {
            log.info("I'm in the logger")
        }

    }

    def t= new TestLog()
    t.doLog()

 I am using Groovy Version: 1.8.0 JVM: 1.6.0_20 and groovypp-0.4.232_1.8.0.jar

I get a similar error using the @Log annotation...

    /home/morris/work/groovy/test_log.gpp: 7: BUG! ClassNode#getTypeClass for java.util.logging.Logger is called before the type class is

Original issue reported on code.google.com by wolfma...@gmail.com on 19 May 2011 at 7:33

GoogleCodeExporter commented 8 years ago

Original comment by alex.tka...@gmail.com on 19 May 2011 at 11:03

GoogleCodeExporter commented 8 years ago

Original comment by alex.tka...@gmail.com on 15 Jul 2011 at 7:16

GoogleCodeExporter commented 8 years ago
There is new report in the g++ list from Richard regarding the same or similar 
issue

Original comment by alex.tka...@gmail.com on 15 Jul 2011 at 7:17