On Mon, 13 Oct 2025 13:17:37 GMT, Maurizio Cimadamore <[email protected]> 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
