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

Invalid annotations in bridge methods

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8u31
    • Fix Version/s: 9
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      1.8.0_31

      A DESCRIPTION OF THE PROBLEM :
      Annotation with target TYPE_USE seems to be copied to bridge methods. As bridge methods only delegate back to the overloaded method, these annotations are typically invalid. The reproducer shows that the type annotations specifies a PC range which is longer than the byte code of the method.
       
      Probably type annotations shouldn't be copied to bridge methods. Please find reproducer, decompiled class file and analysis here:

      https://gist.github.com/marchof/070ee2c2077bd095ba96


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Byte code processing tools like ASM file to parse files with invalid annotations.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      REPRODUCER:

      The annotation with target TYPE_USE in the method doit(java.lang.Runnable) is copied
      to the bridge method doit(java.lang.Object). While the bridge method only has 8
      instructions, the range of the type annotation has a length of 15.

      ---------- BEGIN SOURCE ----------
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;
       
      public class ClassWithBridgeMethod<T extends Runnable> implements ParameterizedInterface<T> {
       
      @Override
      public void doit(final T t) {

      @TypeUseAnnotation
      Object x = null;

      // Some instructions just to widen the scope of annotation for x
      System.out.println(x);
      System.out.println(x);
      }
       
      }
       
      interface ParameterizedInterface<T> {
      void doit(T arg);
      }
       
      @Target({ ElementType.TYPE_USE })
      @Retention(RetentionPolicy.CLASS)
      @interface TypeUseAnnotation {
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sadayapalam Srikanth Adayapalam
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: