On Tue, 28 Apr 2026 09:01:57 GMT, Per Minborg <[email protected]> wrote:

>> src/java.base/share/classes/java/util/LazyCollections.java line 424:
>> 
>>> 422:         // -1 is used as a sentinel value for zero so we can get
>>> 423:         // stable access for all `size` values.
>>> 424:         private int size;
>> 
>> Aren't these fields missing `@Stable` ?
>
> Most classes are annotated with 
> `@jdk.internal.vm.annotation.TrustFinalFields`, which is a blanket assertion 
> that all plain fields (not array components) are stable.

Hello Per, from what I understand of 
`jdk.internal.vm.annotation.TrustFinalFields`, that annotation only applies for 
`final` fields:

> Indicates all instance final fields declared in the annotated class should be 
> trusted as constants by compilers in `ciField::is_constant`.

`size` and `hash` fields aren't `final` here, so `TrustFinalFields` wouldn't 
play a role for these fields. Like Viktor and Maurizio note, I think these 
fields seem to be missing an explicit `@Stable`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30194#discussion_r3156153845

Reply via email to