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

Incorrect type annotation path with multi-variable declaration and mixed-array notation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9
    • tools

      In the following example, the type path for the annotation on 'y' should be the same as 'x', but it is instead the same as 'z'. The type of 'y' is int[], so using an [array, array] type path is incorrect. (It is the correct type path for 'z', however.)

      === T.java
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Target;

      @Target(ElementType.TYPE_USE) @interface A {}

      class T {
        int @A [] x = {};
        int @A [] y, z [][];
      }
      ===

      $ javac -fullversion T.java
      javac full version "9-ea+163"
      $ javap -v T
      ...
        int[] x;
          descriptor: [I
          flags: (0x0000)
          RuntimeInvisibleTypeAnnotations:
            0: #8(): FIELD

        int[] y;
          descriptor: [I
          flags: (0x0000)
          RuntimeInvisibleTypeAnnotations:
            0: #8(): FIELD, location=[ARRAY, ARRAY]

        int[][][] z;
          descriptor: [[[I
          flags: (0x0000)
          RuntimeInvisibleTypeAnnotations:
            0: #8(): FIELD, location=[ARRAY, ARRAY]

            vromero Vicente Arturo Romero Zaldivar
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: