diff --git a/src/share/vm/memory/metaspaceShared.cpp b/src/share/vm/memory/metaspaceShared.cpp --- a/src/share/vm/memory/metaspaceShared.cpp +++ b/src/share/vm/memory/metaspaceShared.cpp @@ -699,12 +699,11 @@ // Preload classes to be shared. // Should use some os:: method rather than fopen() here. aB. - const char* class_list_path; + char class_list_path_str[JVM_MAXPATHLEN]; if (SharedClassListFile == NULL) { // Construct the path to the class list (in jre/lib) // Walk up two directories from the location of the VM and // optionally tack on "lib" (depending on platform) - char class_list_path_str[JVM_MAXPATHLEN]; os::jvm_path(class_list_path_str, sizeof(class_list_path_str)); for (int i = 0; i < 3; i++) { char *end = strrchr(class_list_path_str, *os::file_separator()); @@ -719,9 +718,8 @@ } strcat(class_list_path_str, os::file_separator()); strcat(class_list_path_str, "classlist"); - class_list_path = class_list_path_str; } else { - class_list_path = SharedClassListFile; + strcpy(class_list_path_str, SharedClassListFile); } int class_count = 0; @@ -737,7 +735,7 @@ tty->print_cr("Loading classes to share ..."); _has_error_classes = false; - class_count += preload_and_dump(class_list_path, class_promote_order, + class_count += preload_and_dump((const char*)class_list_path_str, class_promote_order, THREAD); if (ExtraSharedClassListFile) { class_count += preload_and_dump(ExtraSharedClassListFile, class_promote_order,