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 <fo...@univ-mlv.fr> 于2023年3月25日周六 06:13写道: > ----- Original Message ----- > > From: "Kasper Nielsen" <kaspe...@gmail.com> > > To: "Chris Hegarty" <chegar...@gmail.com> > > Cc: "core-libs-dev" <core-libs-dev@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 >