Skip to content

8364034: [lworld] Pre-register boxing classes in class loaders #1517

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

Closed
wants to merge 7 commits into from

Conversation

fparain
Copy link
Collaborator

@fparain fparain commented Jul 24, 2025

Add pre-registration of boxing classes when a class loader is registered by the VM.


Progress

  • Change must not contain extraneous whitespace

Issue

  • JDK-8364034: [lworld] Pre-register boxing classes in class loaders (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1517

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 24, 2025

👋 Welcome back fparain! 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 Jul 24, 2025

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

8364034: [lworld] Pre-register boxing classes in class loaders

Reviewed-by: coleenp

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 120 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.

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

@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 24, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 24, 2025

Webrevs

@liach
Copy link
Member

liach commented Jul 24, 2025

Are we planning to register Optional next? And do we have a measure for how far the eager registration would go?

@fparain
Copy link
Collaborator Author

fparain commented Jul 24, 2025

Are we planning to register Optional next? And do we have a measure for how far the eager registration would go?

Optional requires a different set of changes because it is not currently a class known by the JVM.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This came out quite nice by reusing the similar CDS code.

ClassLoaderDataGraph::find_or_create(class_loader);
}
if (class_loader() != nullptr && cld->dictionary() != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can just go in the 'else' statement and then you don't have to test if the dictionary is null. Also, rather than ADD_WRAPPER_CLASS, can you make it function that takes the whole name with vmSymbols::java_lang_ since I think you anticipate adding other classes to this.

To this static function, pass JavaThread* current as the first parameter, so it doesn't have to call Thread::current() for each Handle. It's not that bad for performance anymore but I still don't like that we have it.

Maybe:

static void add_wrapper_class(JavaThread* current, Symbol* classname).

assert_locked_or_safepoint(SystemDictionary_lock);
Symbol* name = k->name();
Dictionary* dictionary = loader_data->dictionary();
assert(k->is_loaded(), "must be");
assert(k->class_loader_data() != loader_data, "only for classes defined by a parent loader");
assert(dictionary->find_class(current, name) == nullptr, "sanity");
dictionary->add_klass(current, name, k);
if (dictionary->find_class(current, name) == nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also keep the assert and have it be:
assert(!CDSConfig::is_using_aot_linked_classes() || dictionary->find_class() == nullptr, "Ioi would like this probably");

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, no this assert isn't right because you add wrapper classes when using_aot_linked_classes too. Never mind this.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This looks good.

@fparain
Copy link
Collaborator Author

fparain commented Jul 28, 2025

Coleen,
Thank you for your review and your suggestions.

@fparain
Copy link
Collaborator Author

fparain commented Jul 28, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Jul 28, 2025

Going to push as commit 57a9aef.
Since your change was applied there have been 120 commits pushed to the lworld branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 28, 2025
@openjdk openjdk bot closed this Jul 28, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 28, 2025
@openjdk
Copy link

openjdk bot commented Jul 28, 2025

@fparain Pushed as commit 57a9aef.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants