Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8236210

javac generates wrong annotation for fields generated from record components

    XMLWordPrintable

Details

    • b08

    Backports

      Description

        For this test case:

        import java.lang.annotation.*;

        @Target({ElementType.TYPE_USE, ElementType.RECORD_COMPONENT})
        @Retention(RetentionPolicy.RUNTIME)
        @interface Anno { }

        record R(@Anno String s) {}

        javac decorates the corresponding field with two instances of @Anno, when it should have only one, a type annotation applied to the type of the field. From the class file:

        private final java.lang.String s;
            descriptor: Ljava/lang/String;
            flags: (0x0012) ACC_PRIVATE, ACC_FINAL
            RuntimeVisibleAnnotations:
              0: #27()
                Anno
            RuntimeVisibleTypeAnnotations:
              0: #27(): FIELD
                Anno

        From a test case created by: Dmitry Bessonov

        Attachments

          Issue Links

            Activity

              People

                vromero Vicente Arturo Romero Zaldivar
                vromero Vicente Arturo Romero Zaldivar
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: