On Fri, 21 Oct 2022 12:11:28 GMT, ExE Boss <d...@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