On Tue, 11 Nov 2025 16:56:18 GMT, Rémi Forax <[email protected]> wrote:
> I wonder if it's not better to replace Comparator.naturalOrder() by null in > the constructor of TreeSet, given that TreeSet does not provide a getter for > it so the only way to get the comparator is using > treeSet.spliterator().getComparator(). That wouldn't help with the `stream().sorted(Comparator.naturalOrder())` case; the example I supplied is somewhat contrived, I originally ran into this in Guava (see the [issue](https://github.com/google/guava/issues/6187) I opened there); the library is null-hostile and so always supplies a comparator to its sorted collections. Note that this won't directly fix the issue there until they move away from their custom natural order comparator to the one from the JDK. ------------- PR Comment: https://git.openjdk.org/jdk/pull/28226#issuecomment-3517933722
