JDK-4899337 : generics: compiler rejects mutually recursive type variable bounds
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-07-31
  • Updated: 2004-07-09
  • Resolved: 2004-07-09
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 07/31/2003


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Windows XP

EXTRA RELEVANT SYSTEM CONFIGURATION :
generics prototype compiler 2.2-ea

A DESCRIPTION OF THE PROBLEM :
The prototype compiler rejects mutually recursive type variable bounds although the specification allows them.


package generics;

public class TypeVariablesInBounds {

	  public static <T extends S & Comparable<S>, S extends T>
	  T max(T arg1, S arg2) {
	  	return (arg1.compareTo(arg2)>0)?arg1:arg2;
	  }

}


error message:

TypeVariablesInBounds.java:5: illegal forward reference
	  public static <T extends S & Comparable<S>, S extends T>
                                   ^


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile source

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
error-free compilation
ACTUAL -
compile-time error messages

ERROR MESSAGES/STACK TRACES THAT OCCUR :
TypeVariablesInBounds.java:5: illegal forward reference
	  public static <T extends S & Comparable<S>, S extends T>
                                   ^


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package generics;

public class TypeVariablesInBounds {

	  public static <T extends S & Comparable<S>, S extends T>
	  T max(T arg1, S arg2) {
	  	return (arg1.compareTo(arg2)>0)?arg1:arg2;
	  }

}
---------- END SOURCE ----------
(Incident Review ID: 193242) 
======================================================================

Comments
EVALUATION Surely this isn't supposed to be legal, is it? ###@###.### 2003-07-31 See comments. ###@###.### 2003-08-20
31-07-2003