On Wed, 2 Apr 2025 13:22:44 GMT, Per Minborg <[email protected]> wrote:
>> Implement JEP 502.
>>
>> The PR passes tier1-tier3 tests.
>
> Per Minborg has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Add info that Map#values and Map#entrySet are stable
src/java.base/share/classes/java/lang/StableValue.java line 50:
> 48:
> 49: /**
> 50: * A stable value is a holder of shallowly immutable content that can be
> lazily computed.
This reads as if the content can only be shallowly immutable (not deeply
immutable).
How about saying "effectively immutable" instead?
src/java.base/share/classes/java/lang/StableValue.java line 103:
> 101: * instead, where the content is atomically and lazily computed via a
> 102: * {@linkplain Supplier supplier}. In the example below, the supplier is
> provided in the
> 103: * form of a lambda expression:
I suspect that developers might use the aforementioned snippet without knowing
that under a race multiple logger instances may be created (even if only one is
then used). So I'd put a comment above trySet indicating that.
src/java.base/share/classes/java/lang/StableValue.java line 130:
> 128: * <p>
> 129: * Furthermore, {@code orElseSet()} guarantees that the supplier
> provided is
> 130: * evaluated only once, even when {@code logger.orElseSet()} is invoked
> concurrently.
Suggestion:
* evaluated at most once, even when {@code logger.orElseSet()} is invoked
concurrently.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024907517
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024915663
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024917749