RFR: 8356995: Provide default methods min(T, T) and max(T, T) in Comparator interface [v4]

Tagir F. Valeev tvaleev at openjdk.org
Sat May 24 07:34:39 UTC 2025


On Fri, 23 May 2025 20:37:05 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

>> Tagir F. Valeev has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Make min and max generic
>
> src/java.base/share/classes/java/util/Comparator.java line 200:
> 
>> 198:      * @param   <U> the type of the arguments and the result.
>> 199:      * @return  the larger of {@code a} and {@code b} according to this comparator.
>> 200:      * @throws  ClassCastException if the collection contains elements that are
> 
> What 'collection' meaned here?

Good catch, thank you. The description was copied from `Collections::max`, which is not so appropriate here. I think it's better to copy it from `Comparator::compare` (also, added `@throws NPE` for consistency).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25297#discussion_r2105747341


More information about the core-libs-dev mailing list