8014138: Add VM option to facilitate the writing of CDS tests

Added the -XX:SharedArchiveFile option.

Reviewed-by: coleenp, ccheung, acorn, dcubed, zgu
This commit is contained in:
Harold Seigel 2013-05-14 09:17:52 -04:00
parent b3675a00d9
commit 3aa20631a9
3 changed files with 89 additions and 15 deletions

View file

@ -3182,25 +3182,37 @@ static void force_serial_gc() {
}
#endif // INCLUDE_ALL_GCS
// Sharing support
// Construct the path to the archive
static char* get_shared_archive_path() {
char *shared_archive_path;
if (SharedArchiveFile == NULL) {
char jvm_path[JVM_MAXPATHLEN];
os::jvm_path(jvm_path, sizeof(jvm_path));
char *end = strrchr(jvm_path, *os::file_separator());
if (end != NULL) *end = '\0';
size_t jvm_path_len = strlen(jvm_path);
size_t file_sep_len = strlen(os::file_separator());
shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len +
file_sep_len + 20, mtInternal);
if (shared_archive_path != NULL) {
strncpy(shared_archive_path, jvm_path, jvm_path_len + 1);
strncat(shared_archive_path, os::file_separator(), file_sep_len);
strncat(shared_archive_path, "classes.jsa", 11);
}
} else {
shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal);
if (shared_archive_path != NULL) {
strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1);
}
}
return shared_archive_path;
}
// Parse entry point called from JNI_CreateJavaVM
jint Arguments::parse(const JavaVMInitArgs* args) {
// Sharing support
// Construct the path to the archive
char jvm_path[JVM_MAXPATHLEN];
os::jvm_path(jvm_path, sizeof(jvm_path));
char *end = strrchr(jvm_path, *os::file_separator());
if (end != NULL) *end = '\0';
char *shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(jvm_path) +
strlen(os::file_separator()) + 20, mtInternal);
if (shared_archive_path == NULL) return JNI_ENOMEM;
strcpy(shared_archive_path, jvm_path);
strcat(shared_archive_path, os::file_separator());
strcat(shared_archive_path, "classes");
strcat(shared_archive_path, ".jsa");
SharedArchivePath = shared_archive_path;
// Remaining part of option string
const char* tail;
@ -3291,6 +3303,12 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
return result;
}
// Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed.
SharedArchivePath = get_shared_archive_path();
if (SharedArchivePath == NULL) {
return JNI_ENOMEM;
}
// Delay warning until here so that we've had a chance to process
// the -XX:-PrintWarnings flag
if (needs_hotspotrc_warning) {