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

(ann) A type variable with multiple bounds does not correctly place type annotation

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      If two type annotations are placed on two bounds, the reflection API does not consider the bound's index such that an exception is thrown when the reflection API parses the annotations.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the example code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exception is thrown and the type annotations are returned correctly.
      ACTUAL -
      An exception is thrown.

      ---------- BEGIN SOURCE ----------
      public class Foo<T extends Callable<@Foo.SampleTypeAnnotation ?> & List<@Foo.SampleTypeAnnotation ?>> {

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

          public static void main(String[] args) throws Exception {
              TypeVariable<Class<Foo>>[] variables = Foo.class.getTypeParameters();
              AnnotatedType[] bounds = variables[0].getAnnotatedBounds();
              System.out.println(bounds[0] instanceof AnnotatedParameterizedType);
              AnnotatedParameterizedType callable = (AnnotatedParameterizedType) bounds[0];
              callable.getAnnotatedActualTypeArguments(); // throws exception
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None.

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: