RFR: 8348028: Unable to run gtests with CDS enabled

Ioi Lam iklam at openjdk.org
Wed Feb 26 02:42:05 UTC 2025


On Tue, 25 Feb 2025 00:51:55 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:

> A simple fix in `os::jvm_path()` so that gtest can be run with CDS (`-Xshare:on`). The fix is just to change the directory name from `hotspot` to `server`.
> Note that the bug doesn't exist on macOS and thus no change is required for `os_bsd.cpp`.
> 
> Testing:
> 
> - run gtest with -Xshare:on on linux-x64
> - tier1

An alternative suggestion:

Instead of finding the default archive in the same directory as `os::jvm_path()`, which is wrong when using gtestLauncher

https://github.com/openjdk/jdk/blob/037e47112bdf2fa2324f7c58198f6d433f17d9fd/src/hotspot/share/cds/cdsConfig.cpp#L90-L97

We should find it from  `Arguments::get_java_home()`:


   stringStream tmp;
   const char* subdir = WINDOWS_ONLY("bin") NOT_WINDOWS("lib");
   tmp.print("%s%s%s%s%sclasses", Arguments::get_java_home(), os::file_separator(), subdir,
             JVM_VARIANT, os::file_separator());


We need to modify make/hotspot/lib/JvmFeatures.gmk to add this at the top of the file:


JVM_CFLAGS_FEATURES += -DJVM_VARIANT="$(JVM_VARIANT)"


Note: the location of the default CDS archives are decided here:

https://github.com/openjdk/jdk/blob/037e47112bdf2fa2324f7c58198f6d433f17d9fd/make/Images.gmk#L150-L154

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23758#issuecomment-2683749734


More information about the hotspot-runtime-dev mailing list