[External] : Re: Feedback about LazyConstants API (JEP526)
Anatoly Kupriyanov
kan.izh at gmail.com
Tue Dec 9 11:59:46 UTC 2025
I don't think it's a problem. To be honest, I don't really see why this
method causes such confusion.. It behaves very similarly to the Optional's
method of the same name. I would support the Red IO suggestion to have a
`tryGet` method returning Optional as a way to tackle the confusion.
If you read javadoc for orElse it says "Returns the constant if
initialized, otherwise, returns other", which is quite literally what I did
show in my code snippet. Logically it is the same, but you are right, from
implementation perspective it uses getAcquire twice, which potentially
could have performance penalty.
Your code snippet is incorrect, as the `get` never throws.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20251209/8587201e/attachment.htm>
More information about the amber-dev
mailing list