8168797: do not load any archived classes from a patched module

Add new runtime shared class visibility check to ensure shared classes from patched module are not loaded at runtime.

Reviewed-by: acorn, ccheung, hseigel, iklam, lfoltan
This commit is contained in:
Jiangli Zhou 2016-12-19 13:54:33 -05:00
parent a601028e0f
commit bae7bbd382
9 changed files with 31 additions and 210 deletions

View file

@ -1324,12 +1324,15 @@ void Arguments::check_unsupported_dumping_properties() {
"jdk.module.limitmods",
"jdk.module.path",
"jdk.module.upgrade.path",
"jdk.module.addmods.0" };
const char* unsupported_options[] = { "-m",
"--limit-modules",
"--module-path",
"--upgrade-module-path",
"--add-modules" };
"jdk.module.addmods.0",
"jdk.module.patch.0" };
const char* unsupported_options[] = { "-m", // cannot use at dump time
"--limit-modules", // cannot use at dump time
"--module-path", // ignored at dump time
"--upgrade-module-path", // ignored at dump time
"--add-modules", // ignored at dump time
"--patch-module" // ignored at dump time
};
assert(ARRAY_SIZE(unsupported_properties) == ARRAY_SIZE(unsupported_options), "must be");
// If a vm option is found in the unsupported_options array with index less than the warning_idx,
// vm will exit with an error message. Otherwise, it will result in a warning message.
@ -1420,10 +1423,8 @@ void Arguments::set_mode_flags(Mode mode) {
}
}
#if defined(COMPILER2) || INCLUDE_JVMCI || defined(_LP64) || !INCLUDE_CDS
// Conflict: required to use shared spaces (-Xshare:on), but
// incompatible command line options were chosen.
static void no_shared_spaces(const char* message) {
if (RequireSharedSpaces) {
jio_fprintf(defaultStream::error_stream(),
@ -1433,7 +1434,6 @@ static void no_shared_spaces(const char* message) {
FLAG_SET_DEFAULT(UseSharedSpaces, false);
}
}
#endif
// Returns threshold scaled with the value of scale.
// If scale < 0.0, threshold is returned without scaling.
@ -2682,6 +2682,12 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
return result;
}
#if INCLUDE_CDS
if (UseSharedSpaces && patch_mod_javabase) {
no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
}
#endif
return JNI_OK;
}
@ -4410,7 +4416,6 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
}
jint Arguments::apply_ergo() {
// Set flags based on ergonomics.
set_ergonomics_flags();