StableValue vs Optional

Mickael Istria mistria at redhat.com
Tue Jun 17 14:25:51 UTC 2025


On Tue, Jun 17, 2025 at 3:34 PM Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:

> Note that this is already part of the StableValue API:
> https://download.java.net/java/early_access/jdk25/docs/api/java.base/java/lang/StableValue.html#supplier(java.util.function.Supplier)
>

Yes, that's where my thoughts incepted. When I noticed it, I wondered
whether a new type is the best solution for lazy initialization of final
values (and still believe a Supplier.cache(Supplier<T> computer) would be a
nice addition). But your answer about the scope of StableValue being
broader than just lazy initialization makes my comment not so relevant.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250617/fd7ddf7d/attachment.htm>


More information about the core-libs-dev mailing list