On Thu, 20 Aug 2026 13:47:18 GMT, Casper Norrbin <[email protected]> wrote:
> Hi everyone, > > The `@Contended` notation is not supported on value classes. The intended > behavior is for the annotation to be ignored without affecting the class > layout. However, value classes are currently still marked as contended > internally. When another class inherits from a value class marked as > contended, this causes padding to be inserted between the inherited fields > and the subclass fields, which causes a crash on debug builds. > > To fix this, I have changed the handling so that a class is only marked as > contended if it is an identity class. Since value classes cannot be > contended, filtering the annotation when it is processed avoids carrying an > invalid state that would require extra checks later on. With this change, > contended and non-contended value classes behave identically, and inheriting > from a value class annotated with `@Contended` no longer introduces padding. > > Testing: > - Oracle tiers 1-3 > - A new regression test covering value and identity subclasses inheriting > from contended and non-contended base value classes. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has now been integrated. Changeset: 62a166a0 Author: Casper Norrbin <[email protected]> URL: https://git.openjdk.org/jdk/commit/62a166a0647bdbb7ef41bcc4c042caed3bc7c638 Stats: 178 lines in 3 files changed: 174 ins; 0 del; 4 mod 8389452: Inherited @Contended annotation corrupts concrete value class layout Reviewed-by: fparain, jsjolen ------------- PR: https://git.openjdk.org/jdk/pull/32470
