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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9
    • Fix Version/s: tbd_major
    • Component/s: tools

      Description

      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]

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated: