Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8340409: [lworld] Simple serialization and deserialization of core migrated classes #1248

Open
wants to merge 4 commits into
base: lworld
Choose a base branch
from

Conversation

RogerRiggs
Copy link
Collaborator

@RogerRiggs RogerRiggs commented Sep 18, 2024

Serialization and deerialization of value classes.
For java.base value classes migrated from identity classes:

  • Must be annotated with jdk.internal.MigratedValueClass (in tests too)
  • Must have a constructor or static factory method:
    • annotated with jdk.internal.value.DeserializeConstrucctor
    • constructor parameters must match order and types of serializable fields of the class
  • Value class must not have superclass with fields; only Object or abstract w/o fields
  • Uses same technique as for Records to extract and concat values from stream to invoke constructor
  • Migrated value classes are serialized using the same format/fields as the identity class

Non-migrated value classes throw InvalidClassException

Along the way, refactored code to break out different modes of deserialization: full custom deserialization with custom data, default deserialization only, externalizable, no local class, record, and then added mode to deserialize a value class.

Updates to value class tests and added a combo test to check many combinations of value and identity classes with different parameters.


Progress

  • Change must not contain extraneous whitespace

Issue

  • JDK-8340409: [lworld] Simple serialization and deserialization of core migrated classes (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1248

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

Using diff file

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

Webrev

Link to Webrev Comment

…grated classes

Serialization and deerialization of value classes.
For java.base value classes being migrated from identity classes:
  - Must be annotated with jdk.internal.MigratedValueClass (in tests too)
  - Must have a constructor or static factory method:
    - annotated with jdk.internal.value.DeserializeConstrucctor
    - constructor parameters must match order and types of serializable fields of the class
  - Value class must not have superclass with fields; only Object or abstract w/o fields
  - Uses same technique as for Records to extract and concat values from stream to invoke constructor
  - Migrated value classes are serialized using the same format/fields as the identity class

Non-migrated value classes throw InvalidClassException

Along the way, refactored code to break out different modes of deserialization:
full custom deserialization with custom data, default deserialization only,
externalizable, no local class, record, and then added mode to deserialize a value class.

Updates to value class tests and added a combo test to check many combinations
of value and identity classes with different parameters.
@bridgekeeper
Copy link

bridgekeeper bot commented Sep 18, 2024

👋 Welcome back rriggs! 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
Copy link

openjdk bot commented Sep 18, 2024

@RogerRiggs 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:

8340409: [lworld] Simple serialization and deserialization of core migrated classes

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 1 new commit pushed to the lworld branch:

  • 1a935cb: 8341802: Add test coverage for JVMTI function with value classes

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

➡️ To integrate this PR with the above commit message to the lworld branch, type /integrate in a new comment.

@RogerRiggs RogerRiggs marked this pull request as ready for review September 20, 2024 19:51
@mlbridge
Copy link

mlbridge bot commented Sep 20, 2024

Webrevs

@openjdk
Copy link

openjdk bot commented Sep 24, 2024

@RogerRiggs this pull request can not be integrated into lworld due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8340409-simple-value-deserialize
git fetch https://git.openjdk.org/valhalla.git lworld
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge lworld"
git push

iae.printStackTrace();
return null;
}})
.filter(m -> matchFactoryParamTypes(clazz, m, fields))
Copy link
Contributor

Choose a reason for hiding this comment

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

m can be null here, so matchFactoryParamTypes needs to check that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After setAccessible IAE should never happen; change to throw InternalError.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, sounds good. 👍

Tidy up unreachable IllegalAccessException after setAccessible; throw InternalError.
Move declaration of local into for loop header.
Cleanup TRACE Property parsing.
Improve test output readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants