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

Invalid TypeAnnotation attached to a method body

    XMLWordPrintable

Details

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

    Description

      Javac compiles following source:
      ```
      import java.lang.annotation.Repeatable;
      import java.lang.annotation.Target;
      import static java.lang.annotation.ElementType.TYPE_USE;
      import java.util.function.Supplier;

      @Target(TYPE_USE)
      @Repeatable(AC.class)
      @interface A {
      }

      @Target(TYPE_USE)
      @interface AC {
          A[] value();
      }

      @Target(TYPE_USE)
      @interface B {}

      class Test {
          void test() {
              Supplier<Integer> s = () -> (@A @A @B Integer) 1;
          }
      }
      ```

      Into a class with @AC annotation attached to the test method body and with invalid bytecode offset:
      ```
        void test();
          descriptor: ()V
          flags: (0x0000)
          Code:
            stack=1, locals=2, args_size=1
               0: invokedynamic #7, 0 // InvokeDynamic #0:get:()Ljava/util/function/Supplier;
               5: astore_1
               6: return
            RuntimeInvisibleTypeAnnotations:
              0: #30(#31=[@#32(),@#32()]): CAST, offset=4, type_index=0
                AC(
                  value=[@A,@A]
                )
      ```

      This is preventing the migration of CombinationsTargetTest3 to the ClassFile API; the test should be moved to CF API as part of the fix.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              asotona Adam Sotona
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: