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

Annotations not being correctly placed in native records

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.3
    • 4.0.4
    • None

    Description

      For this code:

      import java.lang.annotation.*
      import groovy.transform.TupleConstructor
      
      @Target([ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER])
      @Retention(RetentionPolicy.RUNTIME)
      public @interface MyAnno { }
      
      @MyAnno
      record Car(String make, @MyAnno String model) { }
      
      assert !Car.getAnnotation(MyAnno)
      assert Car.getMethod('model').getAnnotation(MyAnno)
      assert Car.getConstructor(String, String).getAnnotation(MyAnno)
      assert Car.getConstructor(String, String).getParameterAnnotations()[1][0].annotationType() == MyAnno
      

      Groovy 4 on JDK17 currently fails with:

      Annotation @MyAnno is not allowed on element RECORD_COMPONENT
      

      So, the annotation is showing up where it shouldn't.
      In addition, the annotation isn't showing up in other places where it should.
      TL;DR: We have this working for some cases but not all.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: