RFR: 8351565: Implement JEP 502: Stable Values (Preview) [v6]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Apr 2 08:45:32 UTC 2025


On Mon, 17 Mar 2025 02:56:11 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 246 commits:
>> 
>>  - Merge branch 'master' into implement-jep502
>>  - Clean up exception messages and fix comments
>>  - Rename field
>>  - Rename method and fix comment
>>  - Rework reenterant logic
>>  - Use acquire semantics for reading rather than volatile semantics
>>  - Add missing null check
>>  - Simplify handling of sentinel, wrap, and unwrap
>>  - Fix JavaDoc issues
>>  - Fix members in StableEnumFunction
>>  - ... and 236 more: https://git.openjdk.org/jdk/compare/4e51a8c9...d6e1573f
>
> src/java.base/share/classes/java/lang/StableValue.java line 56:
> 
>> 54:  * , {@linkplain #orElse(Object) orElse()}, or {@linkplain #orElseSet(Supplier) orElseSet()}.
>> 55:  * <p>
>> 56:  * A stable value that is <em>set</em> is treated as a constant by the JVM, enabling the
> 
> Before promoting the "constant" features, I would prefer more details about the transition to set - that setting is really a racy thing and only one actor succeeds in setting, and specify the memory effect (like the final field freeze) as a hb for the set and all subsequent gets that successfully observed that set.

I think the issue in this passage is that it's trying to do two things at once: on the one hand, it's saying "better performance" (which I agree with @liach that maybe it's not the primary concern at this point in time). But it's also saying "you can use it in more places than `final`" -- which is a rather big implication of the API. I suggest focusing on this latter aspect here -- and move any performance-related consideration to a section later (e.g. constant folding)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024354673


More information about the core-libs-dev mailing list