[
https://issues.apache.org/jira/browse/GROOVY-8184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17714331#comment-17714331
]
Eric Milles edited comment on GROOVY-8184 at 4/20/23 2:37 PM:
--------------------------------------------------------------
You can add "import some.pack.SomeJavaClass" or write
"@SomeAnnotation(SomeJavaClass.class)" to work around the chicken-egg problem
that exists with the bi-directional dependencies. The
[JavaAwareCompilationUnit|https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/tools/javac/JavaAwareCompilationUnit.java]
does know about the java sources being compiled but does not know what classes
are declared within.
Here is an example that relies on an import:
https://github.com/apache/groovy/blob/master/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/internal/MatchingConstraintsBuilder.groovy#L71
was (Author: emilles):
You can add "import some.pack.SomeJavaClass" or write
"@SomeAnnotation(SomeJavaClass.class)" to work around the chicken-egg problem
that exists with the bi-directional dependencies. The
[JavaAwareCompilationUnit|https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/tools/javac/JavaAwareCompilationUnit.java]
does know about the java sources being compiled but does not know what classes
are declared within.
Here is an example where it uses an import:
https://github.com/apache/groovy/blob/master/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/internal/MatchingConstraintsBuilder.groovy#L71
> Class constant withouts .class in annotation value resolves as
> VariableExpression
> ---------------------------------------------------------------------------------
>
> Key: GROOVY-8184
> URL: https://issues.apache.org/jira/browse/GROOVY-8184
> Project: Groovy
> Issue Type: Bug
> Components: Stub generator / Joint compiler
> Reporter: Pavel Novichenko
> Assignee: Eric Milles
> Priority: Major
> Labels: annotations
>
> If I write class name of java class in same package without .class inside
> annotation definition, expresson not resolves as ClassExpresson, but
> VariableExpression. In stub generation VariableExpression represents as only
> name of class whithout .class and leading to incorrect java file.
> Example:
> groovy:
> {code}
> @SomeAnnotation(SomeJavaClass)
> class Foo {}
> {code}
> generated stub:
> {code}
> @SomeAnnotation(SomeJavaClass) //should be
> @SomeAnnotation(SomeJavaClass.class)
> public class Foo {}
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)