<i18n dev> RFR: 8366178: Implement JEP 526: Lazy Constants (Second Preview) [v6]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Oct 13 14:33:08 UTC 2025
On Mon, 13 Oct 2025 14:22:13 GMT, Per Minborg <pminborg at openjdk.org> 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.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Define constant folding
src/java.base/share/classes/java/lang/LazyConstant.java line 156:
> 154: * {@code final} fields of any newly created objects, are safely published.
> 155: * <p>
> 156: * If the computing thread or any thread that is blocked by the computing thread
My worry here is that when we say "any thread that is blocked" we really meany "any thread". But in reality this javadoc only refers to threads that are trying to call `get` and end up blocked because some other thread won the race. E.g. if a thread is blocked by the computing thread for any other reason, we don't know whether interrupting that thread will result in an `InterruptedException` ? I think it might be worth simplifying this a bit, starting with the property you want to assert:
> Thread interruption does not cancel initialization of a lazy constant. In other words, if the computing thread is
> interrupted, `LazyConstant::get` doesn't clear the interrupted thread’s status is not cleared, nor does it throw
> an `InterruptedException`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27605#discussion_r2426515394
More information about the i18n-dev
mailing list