The non-deterministic iteration order of Immutable Collections
-
liangchenblue at gmail.com
Fri Mar 24 18:03:21 UTC 2023
https://github.com/openjdk/jdk/blob/97649489d078a3aa34a73e7f686e507f34155788/src/java.base/share/classes/java/util/ImmutableCollections.java#L76-L79
Looking at these, it seems you can add `-Xshare:dump` to VM arguments
to obtain a deterministic iteration order for the same JDK builds.
This can help you reproduce the problem reliably.
On Fri, Mar 24, 2023 at 1:02 PM Kasper Nielsen <kasperni at gmail.com> wrote:
>
> >
> > 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.
>
> /Kasper
More information about the core-libs-dev
mailing list