The non-deterministic iteration order of Immutable Collections

Xeno Amess xenoamess at gmail.com
Fri Mar 24 22:30:37 UTC 2023


maybe you can use some java agent to hack in the of function, and change it
to some strange order, to make you see where goes wrong easier?

Remi Forax <forax at univ-mlv.fr> 于2023年3月25日周六 06:13写道:

> ----- Original Message -----
> > From: "Kasper Nielsen" <kasperni at gmail.com>
> > To: "Chris Hegarty" <chegar999 at gmail.com>
> > Cc: "core-libs-dev" <core-libs-dev at openjdk.org>
> > Sent: Friday, March 24, 2023 6:53:51 PM
> > Subject: Re: The non-deterministic iteration order of Immutable
> Collections
>
> >>
> >> I don't (yet) want to be prescriptive in any potential solution. And I
> >> know that this has been discussed before. I mostly just want to start a
> >> conversation and see how much traction it gets.
> >>
> > Would
> > java.util.SequencedMap.of(...)
> > java.util.SequencedMap.copyOf(SequencedMap map)
> > java.util.SequencedSet.of(...)
> > java.util.SequencedSet.copyOf(SequencedSet set)
> > solve your problem?
> >
> > I would love to see them included in JEP 431.
> > Should be fairly simply to implement just have a side
> > array that maintains the elements in order.
>
> I do not think SequenceMap or SequencedSet should be use for copyOf(), Map
> and Collection should be used instead because the iteration order is enough.
>
> This is sadly not something acknowledged by JEP 431, but SequencedSet or
> SequencedMap are not very useful as interfaces for typing the parameters of
> public methods. Like NavigableSet/NavigableMap, they can be handy for
> typing a specific implementation for a field or a local variable but for
> methods, they are not general enough.
>
> >
> > /Kasper
>
> regards,
> Rémi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20230325/c0d8d41d/attachment.htm>


More information about the core-libs-dev mailing list