<i18n dev> RFR: 8366178: Implement JEP 526: Lazy Constants (Second Preview)
Per Minborg
pminborg at openjdk.org
Mon Oct 13 13:46:51 UTC 2025
On Mon, 13 Oct 2025 13:17:37 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Implement JEP 526: Lazy Constants (Second Preview)
>>
>> The lazy list/map implementations are broken out from `ImmutableCollections` to a separate class.
>>
>> The old benchmarks are not moved/renamed to allow comparison with previous releases.
>>
>> `java.util.Optional` is updated so that its field is annotated with `@Stable`. This is to allow `Optional` instances to be held in lazy constants and still provide constant folding.
>
> src/java.base/share/classes/java/util/LazyCollections.java line 360:
>
>> 358:
>> 359: @Stable
>> 360: private final Set<K> keySet;
>
> I believe putting the field in here might cause some redundancies -- for instance LazyMap extends this class and addss a `Map<K, Integer>`, from which you can clearly derive the key set...
It is true that `AbstractMap` already contains a `keySet` field. If we annotate `AbstractMap.keySet` with `@Stable` (which seems ok to do), we can get rid of this field. A note here is that eventually, we would like to get rid of all the fields in `AbstractMap`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27605#discussion_r2426399337
More information about the i18n-dev
mailing list