Ambiguous reference

Zhong Yu zhong.j.yu at
Wed Nov 13 11:14:37 PST 2013

One thing I find quite worrisome in the new overload resolution - In
Java7, applicable methods are "actually" applicable. The "choosing the
most specific method" step is guaranteed to chose an actually
applicable method.

In Java8, that's not the case in a lot of times. Applicable methods
may not be actually applicable, and the "most specific" step may
choose a method that fails to pass further compilation.

This can be quite confusing to the programmer:

case 1. javac reports ambiguity because two methods are applicable -
while it is very clear to the programmer that one of the method is not
actrually applicable.

case 2. javac chooses the most specific method, then finds that it is
not actually applicable, reports that arguments do not fit the
parameter types - while it seems very clear to the programmer that
this method should not be a candidate in the first place.

Zhong Yu

More information about the lambda-dev mailing list