On Wed, 21 May 2025 19:20:38 GMT, Peter Levart <plev...@openjdk.org> wrote:
>> Tagir F. Valeev has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Return first argument in case of tie (to be consistent with >> BinaryOperator); junit tests > > What I was trying to say is that not only would Guava's Ordering not compile > any more (it would still be binary compatible I think, as both methods have > same erasure), but I also think that generic max and min as defined by > Guava's Ordering are more useful too. So what do you think of making them > generic like this: > > > default <E extends T> E max(E e1, E e2) { > return compare(e1, e2) >= 0 ? e1 : e2; > } > > default <E extends T> E min(E e1, E e2) { > return compare(e1, e2) <= 0 ? e1 : e2; > } @plevart this is definitely a good idea, and it will make the methods more convenient. I used `U` as a new type parameter, because it looks like it's more common in the OpenJDK codebase (e.g., `StructuredTaskScope::fork`). Now, Guava should be source-compatible, though it's possible that some other libraries declare non-generic min/max and they will not be source-compatible anymore. I'll mention this in CSR. ------------- PR Comment: https://git.openjdk.org/jdk/pull/25297#issuecomment-2900176890