Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.3.7
-
None
-
None
Description
groovyc fails to generate compiling Java stub for Groovy classes which use statically imported field as an annotation parameter. E.g.
import static stub.Constants.CONST1 class GroovyToStub { @GroovyAnn(CONST1) //fails void methodToStub() { } }
/tmp/groovy-java-stubs/stub/GroovyToStub.java:21: error: cannot find symbol @stub.GroovyAnn(value=CONST1) public void methodToStub() { } ^ symbol: variable CONST1 location: class GroovyToStub 1 error startup failed: Compilation failed; see the compiler error output for details. 1 error
A simple workaround is to use Constants.CONST1 with normal import, but in some cases it can reduce original code readability.
Looking briefly at the code there could be missing "printing" static imports in JavaStubGenerator.printImports().
Sample project reproducing problem:
https://github.com/szpak/code-examples-and-poc/tree/master/groovy-joint-compilation-issue