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

Chen Liang liach at openjdk.org
Thu Apr 24 00:15:02 UTC 2025


On Wed, 23 Apr 2025 12:12:26 GMT, Per Minborg <pminborg at openjdk.org> 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:
> 
>   Replace 'contents' with 'result' in the docs

src/java.base/share/classes/java/lang/StableValue.java line 433:

> 431:  *           provide transitive constantness.
> 432:  *
> 433:  * @implNote Stable values, functions, and collections are not {@link Serializable}.

Suggestion:

 *           <p>
 *           Stable values, functions, and collections are not {@link Serializable}.

src/java.base/share/classes/java/util/Collection.java line 61:

> 59:  * implementations in the Java platform libraries comply.
> 60:  *
> 61:  * <p><a id="optional-operations"></a>Certain methods are specified to be

Suggestion:

 * <p id="optional-operations">Certain methods are specified to be

src/java.base/share/classes/java/util/ImmutableCollections.java line 1616:

> 1614:         }
> 1615: 
> 1616:         final class StableMapValues extends AbstractCollection<V> {

Can this be `AbstractImmutableCollection`? I know we have #18522 debate going on, but we can probably safely port the semantics introduced in that PR to new collections we add in this patch.

src/java.base/share/classes/java/util/ReverseOrderListView.java line 305:

> 303:             final StableValueImpl<E>[] reversed = ArraysSupport.reverse(
> 304:                     Arrays.copyOf(stableList.delegates, stableList.delegates.length));
> 305:             return StableUtil.renderElements(base, "Collection", reversed);

StableList should provide its own SubList class that provide this implementation, instead of hacking the general-purpose view.

src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java line 85:

> 83:         LANGUAGE_MODEL,
> 84:         @JEP(number = 502, title = "Stable Values", status = "Preview")
> 85:         STABLE_VALUES,

Please add your enum constant above `LANGUAGE_MODEL` - it is a reserved key for certain reflective preview APIs.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2057076154
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2057074429
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2057073986
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2057071480
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2057069964


More information about the core-libs-dev mailing list