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

When having annotations the upper bound of generic parameters is ignored

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      ```java
      package org;

      import java.lang.annotation.ElementType;
      import java.lang.annotation.Target;

      public class I<T0, T1 extends T0> {
          T0 func(T1 t1) {
              return t1;
          }
      }

      @Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
      @interface A {
      }

      class B<T2, T3> {
          T2 foo(I<T2, @A T3> a, T3 t3) {
              return a.func(t3);
          }
      }
      ```
      Compile the code above. `I<T2, @A T3> a` is not legal but the compiler accept this.


        1. I.java
          0.3 kB
          Anjana Sajeev

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: