RFR: 8351565: Implement JEP 502: Stable Values (Preview) [v56]
Luca Kellermann
duke at openjdk.org
Fri Apr 25 03:45:10 UTC 2025
On Tue, 22 Apr 2025 11:22:52 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/ImmutableCollections.java line 1592:
>>
>>> 1590: final K k = inner.getKey();
>>> 1591: return new NullableKeyValueHolder<>(k, inner.getValue().orElseSet(new Supplier<V>() {
>>> 1592: @Override public V get() { return mapper.apply(k); }}));
>>
>> I suppose you could potentially make this more lazy by returning an `Entry` implementation that only evaluates the mapper when calling `Entry::getValue`.
>
> Yepp. Interesting idea.
This lazy `Entry` implementation should then also have a `toString` that doesn't evaluate the contents. It should also be used in `forEachRemaining`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2059377365
More information about the core-libs-dev
mailing list