diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index b3c13b63aff..b93238eca88 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -110,12 +110,24 @@ const char* CDSConfig::default_archive_path() { // before CDSConfig::ergo_initialize() is called. assert(_cds_ergo_initialize_started, "sanity"); if (_default_archive_path == nullptr) { - char jvm_path[JVM_MAXPATHLEN]; - os::jvm_path(jvm_path, sizeof(jvm_path)); - char *end = strrchr(jvm_path, *os::file_separator()); - if (end != nullptr) *end = '\0'; stringStream tmp; - tmp.print("%s%sclasses", jvm_path, os::file_separator()); + if (is_vm_statically_linked()) { + // It's easier to form the path using JAVA_HOME as os::jvm_path + // gives the path to the launcher executable on static JDK. + const char* subdir = WINDOWS_ONLY("bin") NOT_WINDOWS("lib"); + tmp.print("%s%s%s%s%s%sclasses", + Arguments::get_java_home(), os::file_separator(), + subdir, os::file_separator(), + Abstract_VM_Version::vm_variant(), os::file_separator()); + } else { + // Assume .jsa is in the same directory where libjvm resides on + // non-static JDK. + char jvm_path[JVM_MAXPATHLEN]; + os::jvm_path(jvm_path, sizeof(jvm_path)); + char *end = strrchr(jvm_path, *os::file_separator()); + if (end != nullptr) *end = '\0'; + tmp.print("%s%sclasses", jvm_path, os::file_separator()); + } #ifdef _LP64 if (!UseCompressedOops) { tmp.print_raw("_nocoops"); diff --git a/test/hotspot/jtreg/ProblemList-StaticJdk.txt b/test/hotspot/jtreg/ProblemList-StaticJdk.txt index c872a97b301..cb727e470f3 100644 --- a/test/hotspot/jtreg/ProblemList-StaticJdk.txt +++ b/test/hotspot/jtreg/ProblemList-StaticJdk.txt @@ -42,12 +42,3 @@ gtest/MetaspaceGtests.java#no-ccs 8356201 generic-all gtest/NMTGtests.java#nmt-detail 8356201 generic-all gtest/NMTGtests.java#nmt-off 8356201 generic-all gtest/NMTGtests.java#nmt-summary 8356201 generic-all - -# Need CDS archive -runtime/cds/NonJVMVariantLocation.java 8357632 generic-all -runtime/cds/TestCDSVMCrash.java 8357632 generic-all -runtime/cds/TestDefaultArchiveLoading.java#coops_coh 8357632 generic-all -runtime/cds/TestDefaultArchiveLoading.java#coops_nocoh 8357632 generic-all -runtime/cds/TestDefaultArchiveLoading.java#nocoops_coh 8357632 generic-all -runtime/cds/TestDefaultArchiveLoading.java#nocoops_nocoh 8357632 generic-all -serviceability/jvmti/RedefineClasses/RedefineSharedClass.java 8357632 generic-all diff --git a/test/hotspot/jtreg/runtime/cds/NonJVMVariantLocation.java b/test/hotspot/jtreg/runtime/cds/NonJVMVariantLocation.java index 81e931e450e..24772d620ad 100644 --- a/test/hotspot/jtreg/runtime/cds/NonJVMVariantLocation.java +++ b/test/hotspot/jtreg/runtime/cds/NonJVMVariantLocation.java @@ -26,6 +26,7 @@ * @test * @summary Test that CDS archive can be loaded if the archive is in a non-JVM variant directory. * @bug 8353504 + * @requires !jdk.static * @requires vm.cds * @requires vm.flagless * @requires vm.flavor == "server"