groovy
  1. groovy
  2. GROOVY-4434

Java stub generator doesn't use FQN for annotation values

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.7.5
    • Fix Version/s: 1.7.6, 1.8-beta-3
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      1

      Description

      After upgrading our app from 1.7.4 to 1.7.5, we got several (joint) compile errors for seemingly simple Groovy classes. Looking at the generated stub code, I found that imports for annotations were always missing. After debugging groovyc, I found the following:

      AntlrParserPlugin:333: addImport() is called with alias==null, which is correct since no import alias is used
      ASTHelper:131: if(aliasName==null) aliasName=name // now alias is non-null
      JavaStubGenerator:679: if (imp.getAlias() == null) imports.add(...); // because getAlias() is non-null, import isn't added

      Code example:

      import foo.Foo // details of Foo don't matter
         
      @Foo
      class Bar {} 
      

      For GMaven users this means that if just one Groovy class in the whole project contains an annotation, the project cannot be compiled.

        Issue Links

          Activity

          Hide
          Guillaume Laforge added a comment -

          Btw, for running a single test, on the command-line, you can do:

          ant -DtestCase=groovy.bugs.ABug test
          
          Show
          Guillaume Laforge added a comment - Btw, for running a single test, on the command-line, you can do: ant -DtestCase=groovy.bugs.ABug test
          Hide
          Peter Niederwieser added a comment -

          > Great. So I will mark this one back as Resolved since it's in GMaven domain now?
          Do as you please. Depending on my findings, I will reopen, add a GMaven issue, or bang my head against the wall (if it's a problem with my setup).

          Show
          Peter Niederwieser added a comment - > Great. So I will mark this one back as Resolved since it's in GMaven domain now? Do as you please. Depending on my findings, I will reopen, add a GMaven issue, or bang my head against the wall (if it's a problem with my setup).
          Hide
          Roshan Dawrani added a comment -

          Reopen anytime you can be sure it is a core groovy issue, but don't just pick blindly from your 3 choices and reopen

          Show
          Roshan Dawrani added a comment - Reopen anytime you can be sure it is a core groovy issue, but don't just pick blindly from your 3 choices and reopen
          Hide
          Roshan Dawrani added a comment - - edited

          Not a core groovy issue - explained why/how.

          Show
          Roshan Dawrani added a comment - - edited Not a core groovy issue - explained why/how.
          Hide
          Peter Niederwieser added a comment - - edited

          Looking at this with the debugger, the only explanation I have is that GMaven's JavaStubCompilationUnit behaves slightly differently than groovyc's JavaAwareCompilationUnit (JavaStubCompilationUnit vs. JavaAwareCompilationUnit is the only difference in the stack trace). With groovyc, AST for annotation attribute value MyEnum.ONE looks like this:

          org.codehaus.groovy.ast.expr.PropertyExpression@4cdf4bfc[object: org.codehaus.groovy.ast.expr.ClassExpression@57f5b4d1[type: foo.MyEnum] property: ConstantExpression[ONE]]
          

          But with GMaven, it looks like this:

          org.codehaus.groovy.ast.expr.PropertyExpression@65f4ba51[object: org.codehaus.groovy.ast.expr.VariableExpression@25f45022[variable: MyEnum] property: ConstantExpression[ONE]]
          

          I've opened GMAVEN-84.

          Show
          Peter Niederwieser added a comment - - edited Looking at this with the debugger, the only explanation I have is that GMaven's JavaStubCompilationUnit behaves slightly differently than groovyc's JavaAwareCompilationUnit (JavaStubCompilationUnit vs. JavaAwareCompilationUnit is the only difference in the stack trace). With groovyc, AST for annotation attribute value MyEnum.ONE looks like this: org.codehaus.groovy.ast.expr.PropertyExpression@4cdf4bfc[object: org.codehaus.groovy.ast.expr.ClassExpression@57f5b4d1[type: foo.MyEnum] property: ConstantExpression[ONE]] But with GMaven, it looks like this: org.codehaus.groovy.ast.expr.PropertyExpression@65f4ba51[object: org.codehaus.groovy.ast.expr.VariableExpression@25f45022[variable: MyEnum] property: ConstantExpression[ONE]] I've opened GMAVEN-84 .

            People

            • Assignee:
              Roshan Dawrani
              Reporter:
              Peter Niederwieser
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: