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

Self-referencing type parameters no longer compile under JDK7

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • tools
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0_03"
      Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7600]

      A DESCRIPTION OF THE PROBLEM :
      The following class will compile under JDK6

          class XY<A extends XY<A, B>, B extends XY<B, A>> { }

      This code no longer compiles. Javac emits the following error:

      XY.java:1: error: type argument B is not within bounds of type-variable A
      class XY<A extends XY<A, B>, B extends XY<B, A>> { }
                                                ^
        where B,A are type-variables:
          B extends XY<B,A> declared in class XY
          A extends XY<A,B> declared in class XY
      1 error


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile this code in a file named XY.java

         class XY<A extends XY<A, B>, B extends XY<B, A>> { }

      with:

        javac XY.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code should compile and produce an XY.class file
      ACTUAL -
      XY.java:1: error: type argument B is not within bounds of type-variable A
      class XY<A extends XY<A, B>, B extends XY<B, A>> { }
                                                ^
        where B,A are type-variables:
          B extends XY<B,A> declared in class XY
          A extends XY<A,B> declared in class XY
      1 error

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      XY.java:1: error: type argument B is not within bounds of type-variable A
      class XY<A extends XY<A, B>, B extends XY<B, A>> { }
                                                ^
        where B,A are type-variables:
          B extends XY<B,A> declared in class XY
          A extends XY<A,B> declared in class XY
      1 error

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
         class XY<A extends XY<A, B>, B extends XY<B, A>> { }
      ---------- END SOURCE ----------

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: