-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8352001: AOT cache should not contain classes injected into built-in class loaders #24046
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
8352001: AOT cache should not contain classes injected into built-in class loaders #24046
Conversation
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
@iklam 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:
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 22 new commits pushed to the
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 |
Webrevs
|
@iklam This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one nit
const char* const file_name = ClassLoader::file_name_for_class_name(class_name, | ||
ik->name()->utf8_length()); | ||
if (!zip->has_entry(current, file_name)) { | ||
log_warning(cds)("class %s cannot be archived because it was not define from %s as claimed", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: define -> defined
|
||
// Define a class using Lookup.defineClass(). The ClassFileParser should see "__JVM_DefineClass__" | ||
// as the source location, so this class will be excluded, as the location is not supported. | ||
static void testWithLookup() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this test capture some kind of output or exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These classes are still loadable (just not from the CDS archive), so there aren't exceptions printed here. These lines check that the classes are not loaded from CDS:
public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception {
if (isDumping(runMode)) {
out.shouldMatch("cds,class.* FakeCodeLocationApp");
out.shouldNotMatch("cds,class.* ClassNotInJar1");
out.shouldNotMatch("cds,class.* ClassNotInJar2");
}
if (runMode.isProductionRun()) {
out.shouldMatch("class,load.* FakeCodeLocationApp .*source: shared objects file");
out.shouldNotMatch("class,load.* ClassNotInJar1 .*source: shared objects file");
out.shouldNotMatch("class,load.* ClassNotInJar2 .*source: shared objects file");
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. I have a question in classLoaderExt.cpp.
@@ -100,4 +100,8 @@ void ClassLoaderExt::record_result(const s2 classpath_index, InstanceKlass* resu | |||
CDSConfig::disable_heap_dumping(); | |||
} | |||
#endif // INCLUDE_CDS_JAVA_HEAP | |||
|
|||
if (CDSConfig::is_dumping_preimage_static_archive() || CDSConfig::is_dumping_dynamic_archive()) { | |||
AOTClassLocationConfig::dumptime()->check_invalid_classpath_index(classpath_index, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case the classpath_index
is invalid, I don't think we should call AOTClassLocationConfig::dumptime_update_max_used_index()
. Maybe the check_invalid_classpath_index()
function should return a bool and have ClassLoaderExt::record_result()
update the classpath index and max used index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. Just one minor comment.
@@ -23,6 +23,7 @@ | |||
*/ | |||
|
|||
#include "cds/aotClassLinker.hpp" | |||
#include "cds/aotClassLocation.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this include needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it by mistake. I've removed it. Could you re-approve?
Thanks @calvinccheung @calvinccheung for the review |
Going to push as commit e433fa2.
Your commit was automatically rebased without conflicts. |
During an application's training run, it's possible to inject classes into the built-in platform/app class loaders with reflection calls.
For safety, this PR filters out such injected classes from the AOT config file.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24046/head:pull/24046
$ git checkout pull/24046
Update a local copy of the PR:
$ git checkout pull/24046
$ git pull https://git.openjdk.org/jdk.git pull/24046/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24046
View PR using the GUI difftool:
$ git pr show -t 24046
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24046.diff
Using Webrev
Link to Webrev Comment