RFR: 8293630: Simplify TreeMap.get() with Comparator.naturalOrder() [v4]
ExE Boss
duke at openjdk.org
Fri Oct 21 12:20:54 UTC 2022
On Fri, 21 Oct 2022 12:11:28 GMT, ExE Boss <duke at openjdk.org> wrote:
>> From one point this is obviously a change in behaviour, from another the spec of `Spliterator.getComparator()` says nothing about serializability of returned comparator and the actual value is hardly ever going to be serialized.
>
> The only new comparator that is returned here is the one returned by `Map.Entry.comparingByKey()`, which is also `Serializable`.
>
> The only place `Comparator.naturalOrder()` is newly used in this PR are the `final` `package‑private` `getEntry` and `getEntryUsingComparator` methods.
Also, `Comparator.naturalOrder()` is implemented using an `enum`, which is naturally `Serializable`:
https://github.com/openjdk/jdk/blob/0c13d66622a8c2be654bb867aa8c17421d1557ca/src/java.base/share/classes/java/util/Comparators.java#L42-L59
-------------
PR: https://git.openjdk.org/jdk/pull/9901
More information about the core-libs-dev
mailing list