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

Wildcard out of bounds error

XMLWordPrintable

    • x86_64
    • generic

      A DESCRIPTION OF THE PROBLEM :
      Error in check of type parameter bounds when wildcard is used as type argument. Same code successfully compiles by Eclipse compiler

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just try to compile provided source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Successful compilation
      ACTUAL -
      /TestClass.java:7: error: type argument ? extends B is not within bounds of type-variable E
              C<? extends A, ? extends B> b = new C<A, B>();
                             ^
        where E,T are type-variables:
          E extends T declared in class C
          T extends Object declared in class C
      1 error

      ---------- BEGIN SOURCE ----------
      public class TestClass {
          public static class A {}
          public static class B extends A {}
          public static class C<T, E extends T> {}

          public static void main(String args[]) {
              C<? extends A, ? extends B> b = new C<A, B>();
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


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

              Created:
              Updated:
              Resolved: