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

javac omits target_path for some type annotations in class extends/implements position

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • tbd
    • 8, 9
    • tools
    • None

      It looks like javac omits the type_path structure for nested types in supertype and implemets targets. In the example below, when looking at GenericSub in javap I get this encoding of @Foo (Note that javap uses type_index and location differently from the vm spec):

      RuntimeVisibleTypeAnnotations:
        0: #18(): CLASS_EXTENDS, type_index=-1, location=[TYPE_ARGUMENT(0)]

      as expected, but when looking at either Impl or SubInner I get:

      RuntimeVisibleTypeAnnotations:
        0: #15(): CLASS_EXTENDS, type_index=0

      or

      RuntimeVisibleTypeAnnotations:
        0: #14(): CLASS_EXTENDS, type_index=-1

      Note the missing type_path (location in javap) for the nesting, which I think table Table 4.7.20.2-E in the vm spec implies.

      --- 8< ---

      import java.lang.annotation.*;
      import java.util.*;
      import java.lang.reflect.*;

      /*
       * @test
       */
      public class LostTypePath {}

      class Super {}
      class Sub extends @Foo Super {}

      class Generic<A> {}
      class GenericSub<B> extends Generic<@Foo B> {}

      class Outer { public static class Inner {}}
      class SubInner extends Outer . @Foo Inner {}

      interface IOuter { public interface IInner {}}
      class Impl implements IOuter . @Foo IInner {}

      @Target(ElementType.TYPE_USE)
      @Retention(RetentionPolicy.RUNTIME)
      @interface Foo {}

            cushon Liam Miller-Cushon
            jfranck Joel Borggrén-Franck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: