RFR: 8360884: Better scoped values [v3]

Andrew Haley aph at openjdk.org
Tue Jul 1 08:23:38 UTC 2025


On Mon, 30 Jun 2025 15:55:03 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> There's something a bit uncomfortable about initializing hashGenerator in ScopedValue's class initializer, then changing it in Constants class initializer. Iimmediately clear what the memory model issues. It doesn't of course matter if the stale value is used but I think confusing on first sight.

That's fair. I think it's a benign race, but I guess that's still a race.

> Have you tried dropping the initializer from ScopedValue so it hashGenerator is only set by Constants? The ScopedValue constructor can call generateKey if hashGenerator is null, and hashGenerator can become a stable field.

That would be more explicit.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26019#discussion_r2176792642


More information about the core-libs-dev mailing list