StableValue and non-deterministic iteration order
Stuart Marks
stuart.marks at oracle.com
Fri Sep 5 19:00:48 UTC 2025
On 9/5/25 12:12 AM, Stephen Colebourne wrote:
> Back in March 2023 there was a discussion about the non-deterministic
> iteration order of Map.of() and friends:
> https://mail.openjdk.org/pipermail/core-libs-dev/2023-March/102865.html
>
> It feels like this discussion should be revisited now that we have
> StableValue. Map.of() is one of the few ways (along with method
> references and records) that we have at the moment to ensure a chain
> of trust through for the JVM so it can constant fold. This should (if
> people are aware) push more people to use Map.of() and friends.
Hi Stephen,
What's the connection between Map.of()'s randomized encounter order and StableValue
or the JIT's ability to constant-fold? Are you observing that randomized encounter
order precludes constant folding? Or are you saying that something should change
near the (preview) StableValue.map() API? For example, that it should specify a
particular encounter order, or that its API signature should change?
s'marks
More information about the core-libs-dev
mailing list