On Wed, 2 Apr 2025 09:17:23 GMT, Per Minborg <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/StableValue.java line 95:
>>
>>> 93: * <p>
>>> 94: * Note that the holder value can only be set at most once.
>>> 95: * In the example above, the {@code logger} field is declared {@code
>>> final} which is
>>
>> This is not 100% true -- a final non-static field is not treated as a
>> constant by the VM (at least not yet). Again, I suggest to keep this
>> discussion focused on the fact that `logger` is a `final` stable value
>> field. The holder is created eagerly, but the _content_ is initialized
>> lazily (in the `getLogger` method). So, same similar to `final` (can only be
>> set once) -- but more flexible.
>
> Now that we have removed the VM-specific handling of fields declared as
> `StableValue`, this is true. I will take a look at improving the wording.
I've used `static` fields now to get out of the muddy waters of trusted final
fields, records etc.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024641249