RFR: 8348028: Unable to run gtests with CDS enabled

David Holmes dholmes at openjdk.org
Tue Feb 25 21:48:52 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

Actually this is historical but not related to actual image on disk:

+  // The next steps are taken in the product version:
+  //
+  // Obtain the JAVA_HOME value from the location of libjvm[_g].so.
+  // This library should be located at:
+  // <JAVA_HOME>/jre/lib/<arch>/{client|server}/libjvm[_g].so.
+  //
+  // If "/jre/lib/" appears at the right place in the path, then we
+  // assume libjvm[_g].so is installed in a JDK and we use this path.
+  //
+  // Otherwise exit with message: "Could not create the Java virtual machine."
+  //
+  // The following extra steps are taken in the debugging version:
+  //
+  // If "/jre/lib/" does NOT appear at the right place in the path
+  // instead of exit check for $JAVA_HOME environment variable.
+  //
+  // If it is defined and we are able to locate $JAVA_HOME/jre/lib/<arch>,
+  // then we append a fake suffix "hotspot/libjvm[_g].so" to this path so
+  // it looks like libjvm[_g].so is installed there
+  // <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm[_g].so.
+  //
+  // Otherwise exit.

It was a "fake" path though I have no idea how it was supposed to be used. I think the current code may be a misunderstanding of the original, but it still has:

+  if (Arguments::sun_java_launcher_is_altjvm()) {
+    // Support for the java launcher's '-XXaltjvm=<path>' option. Typical
+    // value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".
+    // If "/jre/lib/" appears at the right place in the string, then
+    // assume we are installed in a JDK and we're done. Otherwise, check
+    // for a JAVA_HOME environment variable and fix up the path so it
+    // looks like libjvm.so is installed there (append a fake suffix
+    // hotspot/libjvm.so).

This use of a fake path makes absolutely no sense to me, and I don't know how it is supposed to work.

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

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


More information about the hotspot-runtime-dev mailing list