Comparator/Comparators API change proposal

Henry Jen henry.jen at
Tue Jun 4 15:11:42 PDT 2013

On 06/04/2013 02:36 PM, John Rose wrote:
> On Jun 3, 2013, at 2:33 PM, Henry Jen <henry.jen at
> <mailto:henry.jen at>> wrote:
> Moreover, if users leave out the noise words, the code will still
> compile and work almost* the same (due to autoboxing).


> (*Because java.lang.Double comparison is a little different from double
> comparison.)
> E.g., comparing(String::length) == comparing( (Function<String,Integer>)
> String::length ) == comparing( (String s)->s.length() ).
> This extra help to the compiler is needed because it doesn't know
> IntFunction<T> is preferable to Function<T,Integer>, when resolving
> overloadings.
> That is because IntFunction<T> does not extend Function<T,Integer>.
> Is that right?

Your understanding is correct, as the IntFunction<T> to extend
Function<T, Integer>, I think this had been explored before? I didn't
follow through the whole discussion to see why we didn't do that,
perhaps something related to boxing...


More information about the lambda-dev mailing list