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

wrong type checking with lower bounded wildcard

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0-beta2"
      Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
      Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux meco 2.6.10 #1 SMP Wed Aug 31 19:48:13 CEST 2005 i686 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      I have found javac to generate a compiler error for the generic type invocation in the below code even though I understand that the code is correct. The error produced claims that the wildcard type argument "? super C2" is not within the bound of the formal type parameter.

      === $ cat -n A.java
           1 interface I { }
           2 class C1 { }
           3 class C2 extends C1 implements I { }
           4
           5 public class A<T extends C1 & I> {
           6 A<? super C2> a;
           7 }

      === $ javac A.java
      A.java:6: type parameter ? super C2 is not within its bound
          A<? super C2> a;
                    ^
      1 error

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Invoke the javac on the provided code file.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code snippet should compile without errors.
      ACTUAL -
      A compiler error is generated for the generic type invocation.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Compiler error produced by javac:

      A.java:6: type parameter ? super C2 is not within its bound
          A<? super C2> a;
                    ^
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      interface I { }
      class C1 { }
      class C2 extends C1 implements I { }

      public class A<T extends C1 & I> {
          A<? super C2> a;
      }

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: