You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/10/12 19:01:00 UTC

[jira] [Updated] (GROOVY-7155) Java stub generation fails on statically imported field used as annotation parameter

     [ https://issues.apache.org/jira/browse/GROOVY-7155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-7155:
--------------------------------
    Component/s:     (was: Compiler)
                 Stub generator / Joint compiler

> Java stub generation fails on statically imported field used as annotation parameter
> ------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7155
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7155
>             Project: Groovy
>          Issue Type: Bug
>          Components: Stub generator / Joint compiler
>    Affects Versions: 2.3.7
>            Reporter: Marcin Zajaczkowski
>            Priority: Minor
>
> groovyc fails to generate compiling Java stub for Groovy classes which use statically imported field as an annotation parameter. E.g.
> {code}
> import static stub.Constants.CONST1
> class GroovyToStub {
>     @GroovyAnn(CONST1)  //fails
>     void methodToStub() {
>     }
> }
> {code}
> {code}
> /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
> {code}
> 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



--
This message was sent by Atlassian Jira
(v8.3.4#803005)