JDK-5041233 : Cannot override non-trivial generic method
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-05-02
  • Updated: 2004-05-11
  • Resolved: 2004-05-11
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.
Other
5.0 b51Fixed
Related Reports
Relates :  
Description
The following code appears to be legal but does not compile:

    public class AOV {

	protected <T extends Object & Comparable<? super T>> void
	    addObjectValue(String elementName,
			   Class<T> classType,
			   T defaultValue,
			   Comparable<? super T> minValue,
			   Comparable<? super T> maxValue,
			   boolean minInclusive,
			   boolean maxInclusive)
	{ }

	static class Sub extends AOV {

	    protected <T extends Object & Comparable<? super T>> void
		addObjectValue(String elementName,
			       Class<T> classType,
			       T defaultValue,
			       Comparable<? super T> minValue,
			       Comparable<? super T> maxValue,
			       boolean minInclusive,
			       boolean maxInclusive)
	    { }

	}

    }

    % /java/re/jdk/1.5/promoted/all/b49/binaries/linux-i586/bin/javac -source 1.5 AOV.java 
    AOV.java:14: name clash: <T>addObjectValue(java.lang.String,java.lang.Class<T>,T,java.lang.Comparable<? super T>,java.lang.Comparable<? super T>,boolean,boolean) in AOV.Sub and <T>addObjectValue(java.lang.String,java.lang.Class<T>,T,java.lang.Comparable<? super T>,java.lang.Comparable<? super T>,boolean,boolean) in AOV have the same erasure, yet neither overrides the other
	static class Sub extends AOV {
	       ^
    1 error
    % 

It doesn't compile on b32, b47, or b48 either.

-- ###@###.### 2004/5/2

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b51 tiger-beta2
14-06-2004

PUBLIC COMMENTS ...
10-06-2004

EVALUATION This could prevent generification of some libraries. However, this generification may not be possible anyway if the API is extensible by its clients, as making an instance method generic breaks existing overriders. ###@###.### 2004-05-02
02-05-2004

SUGGESTED FIX Correct "same type" check for intersection types. ###@###.### 2004-05-02
02-05-2004