Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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 :
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
- is superceded by
-
GMAVEN-84
GMaven generates incorrect stubs where groovyc generates correct stubs
-
Correction: The problem isn't the missing imports for the annotation types themselves (because the stub generator now uses fully qualified class names for them), but the missing imports for class names appearing in annotation attributes. Example:
Same problem exists for variations like @Foo(val=MyClass) and @Foo(val=MyClass.SOME_CONST).