JDK-6337203 : Clarify binary compatibility rules for bridge methods
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0,6-pool,7-pool,8,9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2005-10-14
  • Updated: 2024-04-12
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
tbdUnresolved
Related Reports
Relates :  
Description
The specification should clarify the rules for binary compatibility
to solve the problem reported in 6337171.
.

Comments
Failure of JCK-Compiler-9: RULE lang/BINC/binc024/binc02413m0/binc02413m0 Exception java.lang.NoSuchMethodError: javasoft.sqe.tests.lang.binc024.binc02413m0.Derived.getThis()Ljavasoft/sqe/tests/lang/binc024/binc02413m0/Derived; Log: http://scaaa008.us.oracle.com:9502/runs%2F518659.ute.st2-1/results/workDir/lang/BINC/binc024/binc02413m0/binc02413m0.jtr
24-06-2014

EVALUATION Bridge methods are non-normative, but JLS 15.12.4.5 needs expanding to require ClassCastException (rather than the default LinkageError) in the following case which doesn't involve overriding. class Base<T extends Base> { public T function() { ... } } class Derived extends Base<Derived> { Derived getThis() { ... } } Derived d = new Derived(); Derived d2 = d.function(); // Statically, Derived has function() which returns Derived. // javac emits an invokevirtual which assumes a return type of Derived, // and verification of the assignment to a Derived var is successful. // Dynamically, d has function() which returns Base. // invokevirtual will fail to resolve a method which returns Derived. The new requirement is basically Peter's suggestion in 6337171: "In the case that a concrete method in a superclass is not overridden explicitly and doing so would require a different descriptor, the compiler must add an implicit override method which forwards to the method in the superclass."
23-04-2007