JDK-6198767 : Unambiguous method calls flagged as ambiguous
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2004-11-22
  • Updated: 2010-04-06
  • Resolved: 2008-12-08
Related Reports
Duplicate :  
Description
The following example does not compile:

interface I1 {
    Integer m1();
}

interface I2 {
    Comparable<?> m1();
}

abstract class C implements I1, I2 {
    void test(C c) {
        c.m1(); // javac claims this call is ambigious
    }
}

The relevant part of JLS (excerpt from 15.12.2.5):

If all the maximally specific methods have override-equivalent
(8.4.2) signatures, then:

* If exactly one of the maximally specific methods is not declared
  abstract, it is the most specific method.

* Otherwise, if all the maximally specific methods are declared
  abstract, and the signatures of all of the maximally specific
  methods have the same erasure (4.6), then the most specific
  method is chosen arbitrarily among the subset of the maximally
  specific methods that have the most specific return type. However,
  the most specific method is considered to throw a checked exception
  if and only if that exception or its erasure is declared in the
  throws clauses of each of the maximally specific methods.

Comments
EVALUATION Closing as not reproducible (duplicate of fixed CR 6487370)
08-12-2008

EVALUATION This is a compiler bug. The problem is most likely the implementation of most specific not being in synch with the spec. ###@###.### 2004-11-22 19:53:47 GMT
22-11-2004