Skip to content

8389452: Inherited @Contended annotation corrupts concrete value class layout - #32470

Open
caspernorrbin wants to merge 2 commits into
openjdk:masterfrom
caspernorrbin:8389452--inherited-contended-corruption
Open

8389452: Inherited @Contended annotation corrupts concrete value class layout#32470
caspernorrbin wants to merge 2 commits into
openjdk:masterfrom
caspernorrbin:8389452--inherited-contended-corruption

Conversation

@caspernorrbin

@caspernorrbin caspernorrbin commented Aug 20, 2026

Copy link
Copy Markdown
Member

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.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8389452: Inherited @Contended annotation corrupts concrete value class layout (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32470/head:pull/32470
$ git checkout pull/32470

Update a local copy of the PR:
$ git checkout pull/32470
$ git pull https://git.openjdk.org/jdk.git pull/32470/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 32470

View PR using the GUI difftool:
$ git pr show -t 32470

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32470.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Aug 20, 2026

Copy link
Copy Markdown

👋 Welcome back cnorrbin! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Aug 20, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot changed the title 8389452 8389452: Inherited @Contended annotation corrupts concrete value class layout Aug 20, 2026
@openjdk openjdk Bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Aug 20, 2026
@openjdk

openjdk Bot commented Aug 20, 2026

Copy link
Copy Markdown

@caspernorrbin The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk

openjdk Bot commented Aug 20, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-runtime. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Aug 20, 2026
@mlbridge

mlbridge Bot commented Aug 20, 2026

Copy link
Copy Markdown

Webrevs

@fparain fparain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.
The fix just needs the update to the Javadoc of @contended we discussed.

@johan-sjolen johan-sjolen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, but please address Frederic's comment.

@openjdk openjdk Bot added the core-libs core-libs-dev@openjdk.org label Aug 21, 2026
@openjdk

openjdk Bot commented Aug 21, 2026

Copy link
Copy Markdown

@caspernorrbin core-libs has been added to this pull request based on files touched in new commit(s).

@fparain fparain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks for the Javadoc update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants