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

Type annotations on inner type that is an array component

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 9, 10, 11
    • Fix Version/s: tbd_minor
    • Component/s: tools
    • Subcomponent:
    • Introduced In Version:
      9

      Description

      Take this example:

      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;

      @Retention(RetentionPolicy.RUNTIME)
      @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
      @interface TA {
        int value();
      }

      class ArrayOfInner {
        class Inner {}

        @TA(1) ArrayOfInner. @TA(2) Inner oi;
        @TA(3) ArrayOfInner. @TA(4) Inner [] oia;
        @TA(5) Inner i;
        @TA(6) Inner [] ia;
      }


      Compile with javac 8 and according to javap -v field ia has the annotation:

        ArrayOfInner$Inner[] ia;
          descriptor: [LArrayOfInner$Inner;
          flags: (0x0000)
          RuntimeVisibleTypeAnnotations:
            0: #10(#11=I#21): FIELD, location=[ARRAY, INNER_TYPE]
              TA(
                value=6
              )

      Compile with javac 9, 10, or a recent 11 build and ia has the annotation:

        ArrayOfInner$Inner[] ia;
          descriptor: [LArrayOfInner$Inner;
          flags: (0x0000)
          RuntimeVisibleTypeAnnotations:
            0: #10(#11=I#21): FIELD, location=[ARRAY]
              TA(
                value=6
              )

      Note the missing INNER_TYPE location.
      The annotations for fields oi, oia, and i are generated consistently
      for all versions and are just included to illustrate all the relevant
      annotation positions.

      The Java 8 behavior was correct and should be re-established.

      Discussion: http://mail.openjdk.java.net/pipermail/compiler-dev/2018-July/012199.html

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sadayapalam Srikanth Adayapalam
                Reporter:
                wmdietl Werner Dietl
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: