RFR: 8348028: Unable to run gtests with CDS enabled

Ioi Lam iklam at openjdk.org
Wed Feb 26 01:11:02 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

For a short-term fix, I think we can take this code from os_bsd.cpp and move it into os.hpp:


// JVM variant
#if   defined(ZERO)
  #define JVM_VARIANT "zero"
#elif defined(COMPILER2)
  #define JVM_VARIANT "server"
#else
  #define JVM_VARIANT "client"
#endif


Then we can do `snprintf(buf + len, buflen-len, "/%s/libjvm.so", JVM_VARIANT);` instead of hard-coding "hotspot". It's no worse than before and solves the immediate problem.

Next, we should completely get rid of `os::jvm_path()`. This API has lots of legacy that we no longer support. It is convoluted and is getting misused. For example,  for `Disassembler::load_library()` to find the hsdis dll, but why do we need to put hsdis.so inside `<home>/lib/<vm>/`? It should just be placed in the same directory as libjava.so. I.e., `$JAVA_HOME/lib`.

https://github.com/openjdk/jdk/blob/037e47112bdf2fa2324f7c58198f6d433f17d9fd/src/hotspot/share/compiler/disassembler.cpp#L811-L812

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

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


More information about the hotspot-runtime-dev mailing list