Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7151

groovyc should accept meta annotation with ElementType.TYPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.0-beta-3
    • 2.5.0-alpha-1
    • Compiler
    • 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

          Activity

            People

              melix Cédric Champeau
              szpak Marcin Zajaczkowski
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: