JDK-7034798 : Ambiguity error for abstract method call is too eager
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-04-07
  • Updated: 2013-07-11
  • Resolved: 2013-07-01
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 8
8 b98Fixed
Related Reports
Relates :  
Relates :  
Description
The following program fails to compile, because the algorithm that identifies a most specific method may require, depending on the order in which methods are considered, that for each pair of methods, one is return-type-substitutable for the other.  This is more strict than the guarantee made by the inheritance rules, which is that there exists at least one method among all those that are override-equivalent that is return-type-substitutable for all the others (JLS 8.4.8.4, 9.4.1).

public class ReturnTypeSubstitutable {

interface A { java.io.Serializable m(); }
interface B { Cloneable m(); }
interface C { Object[] m(); }

interface D extends A, B, C {}
interface E extends C, A, B {}
abstract class F implements A, B, C {}
abstract class G implements C, A, B {}

void test(D d, E e, F f, G g) {
  d.m(); // error
  e.m(); // no error
  f.m(); // error
  g.m(); // no error
}

}

Comments
We now have a place to resolve this: Resolve.AmbiguityError.mergeAbstracts. This routine is called at the end of the overload process when an ambiguity error is about to be thrown. The routine currently does something similar with JDK 7, which is to do a pair-wise RTS check. This needs to be fixed.
24-05-2013