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

Type annotations on non-canonical types result in incorrect type_paths

XMLWordPrintable

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

      Consider:

      ```
      import java.lang.annotation.*;

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

      class One {
        class I {}
      }

      class Two<T> extends One {
        Two<@Foo Object>.I f;
      }
      ```

      The canonical type of `Two<@Foo Object>.I` is `One.I`. When javac compiles this input it produces the following for the field 'f':

        One$I f;
          descriptor: LOne$I;
          flags: (0x0000)
          RuntimeInvisibleTypeAnnotations:
            0: #12(): FIELD, location=[TYPE_ARGUMENT(0)]
              Foo

      Note that the type_path for the type annotation in `Two<@Foo Object>.I` refers to a type argument that does not exist in the canonical type `One.I`.

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

              Created:
              Updated: