8164011: --patch-module support for CDS

Allows the use of the --patch-module vm option with CDS. However, classes found in --patch-module during dump time will not be archived.

Reviewed-by: iklam, dcubed, lfoltan
This commit is contained in:
Calvin Cheung 2016-09-20 10:37:19 -07:00
parent 6085d008cc
commit f9707ab4cd
8 changed files with 268 additions and 38 deletions

View file

@ -86,6 +86,9 @@ void SharedPathsMiscInfo::print_path(int type, const char* path) {
case REQUIRED:
out->print("Expecting that file %s must exist and is not altered", path);
break;
case PATCH_MOD:
out->print("Expecting --patch-module=%s", path);
break;
default:
ShouldNotReachHere();
}
@ -146,6 +149,9 @@ bool SharedPathsMiscInfo::check(jint type, const char* path) {
// But we want it to not exist -> fail
return fail("File must not exist");
}
if ((st.st_mode & S_IFMT) != S_IFREG) {
return fail("Did not get a regular file as expected.");
}
time_t timestamp;
long filesize;
@ -161,7 +167,26 @@ bool SharedPathsMiscInfo::check(jint type, const char* path) {
}
}
break;
case PATCH_MOD:
{
GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
if (patch_mod_args != NULL) {
int num_of_entries = patch_mod_args->length();
for (int i = 0; i < num_of_entries; i++) {
const char* module_name = (patch_mod_args->at(i))->module_name();
const char* path_string = (patch_mod_args->at(i))->path_string();
size_t n = strlen(module_name);
// path contains the module name, followed by '=', and one or more entries.
// E.g.: "java.base=foo" or "java.naming=dir1:dir2:dir3"
if ((strncmp(module_name, path, n) != 0) ||
(path[n] != '=') ||
(strcmp(path + n + 1, path_string) != 0)) {
return fail("--patch-module mismatch, path not found in run time: ", path);
}
}
}
}
break;
default:
return fail("Corrupted archive file header");
}