On Fri, 9 Jan 2026 20:13:29 GMT, Frederic Parain <[email protected]> wrote:
> This would forbid the class which contains the `NULLABLE_NON_ATOMIC_FLAT` > from being flattened into a class which contains it. I think we should only > do so if the holder of the flattened strict final field should not be > flattened if it is not itself a strict final field: > > * The holder is an identity class. > > * The holder is a large value class without `@LooselyConsistentValue`. > > > This is equally valid to null-restricted field of > non-`@LooselyConsistentValue`, too. Yes, there are some restrictions where the NULLABLE_NON_ATOMIC_FLAT can be used, see the comments and the `can_use_atomic_flat` argument in the `field_layout_selection()` method. > I assume this PR is for flattening of nullable fields at immutable memory > (strict final fields) only. But I think the same flattening can be done for > null-free field, right? Strict final null-free fields could also be flattened without having to be concerned about atomicity, but null-freeness is not part of JEP 401. So this case is not supported in this PR. It can be added later when the null-restriction JEP has been finalized. ------------- PR Comment: https://git.openjdk.org/valhalla/pull/1407#issuecomment-3760127181
