Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.0-beta-3
-
None
-
Patch
Description
groovyc fails on a try to annotate Groovy annotation with an annotation with Target set to TargetType.TYPE.
@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Import { Class<?>[] value(); } @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Import(CorrelationIdConfiguration.class) public @interface EnableCorrelationId { } EnableCorrelationId.groovy: 12: Annotation @org.springframework.context.annotation.Import is not allowed on element ANNOTATION @ line 12, column 1. @Import(CorrelationIdConfiguration.class) ^
The same works for Java annotations what follows Java Language Specification:
Type declarations: class, interface, enum, and annotation type declarations (ç8.1.1, ç9.1.1, ç8.5, ç9.5, ç8.9, ç9.6)
Corresponds to java.lang.annotation.ElementType.TYPE
Additionally, annotation type declarations correspond to java.lang.annotation.ElementType.ANNOTATION_TYPE
This is very common in Spring (Boot) application when @Import annotation (which has ElementType.TYPE) is used.
I fixed that and will make a PR in a few minutes (with proper JIRA ticket ID).
Attachments
Issue Links
- is duplicated by
-
GROOVY-7803 Java annotation with @Target(TYPE) on an annotation
- Closed