-
Bug
-
Resolution: Unresolved
-
P4
-
5.0, 6
-
x86
-
linux, windows_xp
When a subtype restricts the bounds of a type variable of its supertype, any inherited methods with a return type of that variable should have a bridge method created. Currently, moving such a method from the derived to base type will cause binary incompatibility.
Care needs to be exercised for protected methods inherited across packages.
JUSTIFICATION :
It should be possible to move such methods to super types, without binary incompatibility.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
$ /usr/java/jdk1.6.0/bin/javap Derived
Compiled from "Derived.java"
public class Derived extends Base{
public Derived();
Derived getThis();
Base getThis();
public Derived function();
}
ACTUAL -
$ /usr/java/jdk1.6.0/bin/javap Derived
Compiled from "Derived.java"
public class Derived extends Base{
public Derived();
Derived getThis();
Base getThis();
}
with 1.5.0_04:
C:\>javac Derived.java
C:\>javap Derived
Compiled from "Derived.java"
public class Derived extends Base{
public Derived();
Derived getThis();
Base getThis();
}
---------- BEGIN SOURCE ----------
abstract class Base<THIS extends Base> {
abstract THIS getThis();
public THIS function() {
return getThis();
}
}
public class Derived extends Base<Derived> {
Derived getThis() {
return this;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Override all methods with this problem.
- duplicates
-
JDK-6481176 java.lang.reflect breaks java generics
- Closed
-
JDK-6506307 (reflect) Method.getReturnType() returns wrong type for overriding methods (generics)
- Closed
- relates to
-
JDK-6406447 MXBean framework should support non-generic subclasses of generic classes
- Resolved
-
JDK-6996415 Override bridges causes compiler-generated code to end up with synthetic infinite loop
- Closed
-
JDK-6476118 compiler bug causes runtime ClassCastException for generics overloading
- Closed
-
JDK-6980862 too aggressive compiler optimization causes stale results of Types.implementation()
- Closed
-
JDK-6986807 TEST failure: java/beans/Introspector/TestTypeResolver.java - List<?extends Integer> should be List?
- Closed
-
JDK-6986811 TEST failure: java/beans/XMLEncoder/Test4994637.java
- Closed
-
JDK-6996758 Investigate better override bridges strategy
- Closed
-
JDK-6337203 Clarify binary compatibility rules for bridge methods
- Open
-
JDK-8005542 jtreg test OverrideBridge.java contains @ignore
- Closed