JDK-7158422 : Self-referencing type parameters no longer compile under JDK7
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2012-04-02
  • Updated: 2012-09-06
  • Resolved: 2012-04-02
Related Reports
Duplicate :  
Description
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 ----------