On Thu, 3 Sep 2026 14:15:36 GMT, Tagir F. Valeev <[email protected]> wrote:

>> Just weighing in: I suspect that this isn't really solvable without risking 
>> breakage. If `sorted()` is to also enforce that `prev.compareTo(next)` is 
>> aligned with the result of `prev.equals(next)` then usages that are 
>> currently working will cease to work: 
>> 
>> 
>> jshell> (new BigDecimal("0.0")).compareTo(new BigDecimal("0.00"))
>> $1 ==> 0
>> 
>> jshell> (new BigDecimal("0.0")).equals(new BigDecimal("0.00"))
>> $2 ==> false
>> 
>> 
>> If instead a distinct() following a sorted() always re-processes the entire 
>> Stream, then it would risk changing the output of existing Stream usages 
>> (silently). 🤔
>
> @viktorklang-ora right. Honestly, I would leave it as is.

Hi @amaembo @JnRouvignac @viktorklang-ora 
Thanks all for the review. Agreed the sorted specialization has little benefit 
with a persistent HashSet, and I haven't benchmarked it yet. Given the 
compareTo/equals compatibility concerns, what direction do you prefer for 
JDK-8223933 — leave as-is, apply a full equals-based fix, or something else? 
I'll update or withdraw the PR accordingly.

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

PR Comment: https://git.openjdk.org/jdk/pull/32670#issuecomment-5528557841

Reply via email to