On Tue, 1 Jul 2025 11:15:54 GMT, Andrew Haley <[email protected]> wrote:
>> Scoped values cannot be used early in the JDK boot process because of some
>> dependencies on System.getProperty(). This dependency should be removed in a
>> way that allows scoped values to be created (but not necessarily bound) at
>> any stage during boot.
>>
>> Also, Scoped Value's constructor has a synchronized block, which limits the
>> use of scoped values at runtime. Constructing a scoped value should be a
>> thread-local operation.
>
> Andrew Haley has updated the pull request incrementally with two additional
> commits since the last revision:
>
> - 8360884: Better scoped values
> - 8360884: Better scoped values
src/java.base/share/classes/java/lang/ScopedValue.java line 534:
> 532:
> 533: private ScopedValue() {
> 534: this.hash = hashGenerator != null ? hashGenerator.getAsInt() :
> generateKey();
The updated version looks much better. It might just a bit clearer to read
hashGenerator once here (it doesn't matter of course but stable fields tend to
attract a lot of questions).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26019#discussion_r2177930532