On Tue, 31 Mar 2026 06:06:43 GMT, Axel Boldt-Christmas <[email protected]> 
wrote:

>> @xmas92 It can. It is a static final field so its result is naturally 
>> trusted, adding `@Stable` would actually untrust its `false` value. Check 
>> `ciField.cpp`.
>
> Good to know. So `@Stable` is only useful for non final fields.
> 
> Is the reason that the box caches `cache` fields are not final, (and 
> `@Stable` instead)? Some AOT / CDS interaction?

There are some inconsistencies. For instance, Integer sees its `cache` as 
non-final, so I think a `@Stable` makes sense there given that the setup is 
performed outside of the static initializer. It's not immediately clear to me 
why this decision was made, but this is also how it is in mainline.

Moving forwards, I propose:
* Ensure all `cache` variables are consistent with mainline and either `static 
final` or `@Stable static`.
* If in preview, `static final` caches with `null` and `@Stable static` caches 
with an empty array.
* Remove `isEnabled`.
* Revert changes in `valueOf`, i.e., call `PreviewFeatures`. 

Thoughts?

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2249#discussion_r3014329988

Reply via email to