Skip to content

8387417: [lworld] API doc improvements for java.lang.Object#2588

Open
AlanBateman wants to merge 9 commits into
openjdk:lworldfrom
AlanBateman:Clone
Open

8387417: [lworld] API doc improvements for java.lang.Object#2588
AlanBateman wants to merge 9 commits into
openjdk:lworldfrom
AlanBateman:Clone

Conversation

@AlanBateman

@AlanBateman AlanBateman commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Updates to java.lang.Object API docs:

  • Improve preview-comment in class description that defines value class and value object
  • Update spec for the finalize method to make it clear when finalize method of a value class is never invoked by the garbage collector
  • Update the implSpec for the clone to specify behavior of Object.clone for value objects. Also add paragraph to method description for value objects, and add API note to advise using copy constructors or static factory methods instead
  • Improve preview-comment in wait/notify methods and drop confusing addition to IMSE exception

A sanity test is added, this depends on the fix to finalizer registration in pull/2589.



Progress

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

Issue

  • JDK-8387417: [lworld] API doc improvements for java.lang.Object (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2588

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2588.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jun 26, 2026

Copy link
Copy Markdown

👋 Welcome back alanb! A progress list of the required criteria for merging this PR into lworld 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 Jun 26, 2026

Copy link
Copy Markdown

@AlanBateman This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8387417: [lworld] API doc improvements for java.lang.Object

Reviewed-by: jpai, liach

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 5 new commits pushed to the lworld branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@liach) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

Comment thread src/java.base/share/classes/java/lang/Object.java Outdated
Comment thread test/jdk/java/lang/Object/ValueObjects.java Outdated
@AlanBateman AlanBateman changed the title [lworld] API doc improvements for java.lang.Object 8387417: [lworld] API doc improvements for java.lang.Object Jun 29, 2026
@AlanBateman AlanBateman marked this pull request as ready for review June 29, 2026 18:53
@openjdk openjdk Bot added the rfr Pull request is ready for review label Jun 29, 2026
@mlbridge

mlbridge Bot commented Jun 29, 2026

Copy link
Copy Markdown

Webrevs

* {@link IdentityException}.
* When preview features are enabled, subclasses of {@code java.lang.Object}
* are either {@linkplain Class#isValue value classes} or identity classes.
* A <em>value object</em> is an instance of a non-abstract value class. All

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hello Alan, in several other places in the other JDK, we seem to refer to such classes as concrete value class. Should we do the same here instead of saying non-abstract value class?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Defining a value object as an instance of non-abstract value classes works here, it's similar to the wording in the changes for the JLS.

@liach liach Jun 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer to phrase it like "the class of a value object is a value class", more in line with code like o.getClass().isValue().

However, Valhalla models "identity" as the extra thing, so I guess it is better to go like "An identity object is an object whose class is an identity class or an array type. All other objects are value objects."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to keep this sentence as proposed as it keeps it consistent with the JLS and keeps the ordering that the terms are introduces consistent with the first sentence. I would be a bit wary of "All other objects are value objects" as it hints that there are other things that are also value classes.

Comment thread src/java.base/share/classes/java/lang/Object.java Outdated
@@ -104,6 +105,7 @@ protected void finalize() {
* Test that the finalize method on an abstract value value is not invoked by the GC.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Typo - should have been "abstract value class ..."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well spotted.

@jaikiran jaikiran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the update. This looks good to me.

@liach liach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The introductory paragraph in class spec might be subject to further discussion to introduce people to "identity is the extra thing" view, but that shouldn't be a blocker.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants