On Fri, 24 Apr 2026 09:02:04 GMT, Per Minborg <[email protected]> wrote:

>> Implement JEP 531: Lazy Constants (Third Preview)
>> 
>> This PR replaces _draft_ https://github.com/openjdk/jdk/pull/29507
>> 
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Per Minborg has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Change the way throwing toString is handled

src/java.base/share/classes/java/lang/LazyConstant.java line 159:

> 157:  * the initialized constant's content is read. Hence, the initialized 
> constant's content,
> 158:  * including any {@code final} fields of any newly created objects, is 
> safely published.
> 159:  * As reading of the content might be elided, there are no other memory 
> ordering or

I find this sentence a bit odd -- you say in the para above that the content of 
the LC are safely published -- which implies there is at least some memory 
ordering between initialization and a get that sees the initialized value (or 
an error state). It seems to me this new para applies more to subsequent reads?

src/java.base/share/classes/java/lang/LazyConstant.java line 180:

> 178:  * to a lazy constant.
> 179:  *
> 180:  * @apiNote Once a lazy constant is initialized, its content cannot ever 
> be removed.

Consider just saying "can't be removed"

src/java.base/share/classes/java/lang/LazyConstant.java line 228:

> 226:      * initialized.
> 227:      * <p>
> 228:      * If an unchecked exception is thrown when evaluating the computing 
> function, this

Doesn't say anything about nulls returned by the computing function?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/30194#discussion_r3145988350
PR Review Comment: https://git.openjdk.org/jdk/pull/30194#discussion_r3145994046
PR Review Comment: https://git.openjdk.org/jdk/pull/30194#discussion_r3146000438

Reply via email to