mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8204620: ModuleEntry::is_non_jdk_module() determination for what is a jdk module is incorrect
Check module's loader and compare version with java.base's version to improve algorithm Reviewed-by: lfoltan, mchung
This commit is contained in:
parent
c97262c785
commit
2595bdf177
4 changed files with 65 additions and 9 deletions
|
@ -56,15 +56,33 @@ void ModuleEntry::set_location(Symbol* location) {
|
|||
}
|
||||
}
|
||||
|
||||
bool ModuleEntry::is_non_jdk_module() {
|
||||
ResourceMark rm;
|
||||
// Return true if the module's version should be displayed in error messages,
|
||||
// logging, etc.
|
||||
// Return false if the module's version is null, if it is unnamed, or if the
|
||||
// module is not an upgradeable module.
|
||||
// Detect if the module is not upgradeable by checking:
|
||||
// 1. Module location is "jrt:/java." and its loader is boot or platform
|
||||
// 2. Module location is "jrt:/jdk.", its loader is one of the builtin loaders
|
||||
// and its version is the same as module java.base's version
|
||||
// The above check is imprecise but should work in almost all cases.
|
||||
bool ModuleEntry::should_show_version() {
|
||||
if (version() == NULL || !is_named()) return false;
|
||||
|
||||
if (location() != NULL) {
|
||||
ResourceMark rm;
|
||||
const char* loc = location()->as_C_string();
|
||||
if (strncmp(loc, "jrt:/java.", 10) != 0 && strncmp(loc, "jrt:/jdk.", 9) != 0) {
|
||||
return true;
|
||||
ClassLoaderData* cld = loader_data();
|
||||
|
||||
if ((cld->is_the_null_class_loader_data() || cld->is_platform_class_loader_data()) &&
|
||||
(strncmp(loc, "jrt:/java.", 10) == 0)) {
|
||||
return false;
|
||||
}
|
||||
if ((ModuleEntryTable::javabase_moduleEntry()->version()->fast_compare(version()) == 0) &&
|
||||
cld->is_permanent_class_loader_data() && (strncmp(loc, "jrt:/jdk.", 9) == 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModuleEntry::set_version(Symbol* version) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue