JDK-6880344 : Recursive type parameters do not compile
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2009-09-09
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b97Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b70)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b07, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux n050409 2.6.22.19-lustre.1.6.5.1 #2 SMP Tue Oct 28 14:06:20 CET 2008 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
Compilation of a recursive type parameter usage gives an error. Compilation on JDK 1.6 works.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac -d . Fact_j17.java


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiles without errors.
ACTUAL -
compile errors


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Fact_j17.java:6: type parameter AlgebraicNumber<C> is not within its bound
    public Fact_j17<AlgebraicNumber<C>> xyz;
                                   ^
  where C is a type-variable:
    C extends GcdRingElem<C> declared in class Fact_j17
1 error


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Fact_j17<C extends GcdRingElem<C>> {
    public Fact_j17<AlgebraicNumber<C>> xyz;
}

class AlgebraicNumber<C extends GcdRingElem<C>> implements GcdRingElem<AlgebraicNumber<C>> {
}

interface GcdRingElem<C extends GcdRingElem<C>> {
}

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

CUSTOMER SUBMITTED WORKAROUND :
stay with JDK 1.6

Release Regression From : 6u16
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/e9ef849ae0ed
19-05-2010

EVALUATION This is a regression from 7 b48 - the problem has been uncovered by the fix for 6729401 - but that fix in itself is fine. Unfortunately the fix has uncovered a bug in Types.isSameType not handling type-variables correctly. This what cause this problem.
09-09-2009