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

Invalid RuntimeVisibleTypeAnnotations for annotation on anonymous class type parameter

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 12
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b18

      Description

      In the following example the method 'f' has an incorrect CLASS_EXTENDS RuntimeVisibleTypeAnnotations attribute. The annotation is actually associated with the type argument of an anonymous class inside the method body.

      ===
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;
      import java.util.concurrent.Callable;

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

      class T {
        private void f() {
          new Callable<@Foo Object>() {
            public Object call() {
              return null;
            }
          };
        }
      }
      ===

      $ javac -fullversion T.java && /google/data/ro/
      javac full version "11-ea+3"
      $ javap -p -v T
      ...

        private void f();
          descriptor: ()V
          flags: (0x0002) ACC_PRIVATE
          Code:
            stack=3, locals=1, args_size=1
               0: new #2 // class T$1
               3: dup
               4: aload_0
               5: invokespecial #3 // Method T$1."<init>":(LT;)V
               8: pop
               9: return
            LineNumberTable:
              line 13: 0
              line 18: 9
          RuntimeVisibleTypeAnnotations:
            0: #13(): CLASS_EXTENDS, type_index=0, location=[TYPE_ARGUMENT(0)]
              Foo

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cushon Liam Miller-Cushon
                Reporter:
                cushon Liam Miller-Cushon
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: