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

@Slf4j throws error in Groovy 2.0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1
    • None
    • None
    • Linux
      java version "1.7.0_03"
      Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
      Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

    Description

      groovyc throws a stacktrace compiling a class with the @Slf4j in Groovy 2.0. The same source compiles in 1.8.6.

      Source file:

      import groovy.util.logging.Slf4j
      @Slf4j
      class Test {
          Test() { log.debug "Here" }
      }
      

      groovyc output:

      >>> a serious error occurred: BUG! exception in phase 'class generation' in source unit 'Test.groovy' ClassNode#getTypeClass for org.slf4j.Logger is called before the type class is set 
      >>> stacktrace:
      BUG! exception in phase 'class generation' in source unit 'Test.groovy' ClassNode#getTypeClass for org.slf4j.Logger is called before the type class is set 
      	at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1327)
      	at org.codehaus.groovy.classgen.asm.BytecodeHelper.box(BytecodeHelper.java:596)
      	at org.codehaus.groovy.classgen.asm.OperandStack.box(OperandStack.java:205)
      	at org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:233)
      	at org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:221)
      	at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:270)
      	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:229)
      	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:76)
      	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.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:354)
      	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.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155)
      	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.visitConstructor(ClassCodeVisitorSupport.java:119)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructor(AsmClassGenerator.java:392)
      	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1052)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
      	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:181)
      	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 org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:496)
      	at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:57)
      	at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:213)
      	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:146)
      	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:176)
      	at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:160)
      	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)
      

      Attachments

        1. Test.groovy
          0.1 kB
          Matt Cholick

        Issue Links

          Activity

            People

              melix Cédric Champeau
              cholick Matt Cholick
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: