RFR: 8353938: hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java fails on static JDK

Jiangli Zhou jiangli at openjdk.org
Tue Apr 8 02:31:57 UTC 2025


Please review this PR that changes `LoadAgentDcmdTest.getLibInstrumentPath()` to not locate `libinstrument` shared library if running on static JDK, instead just returns "libinstrument.<ext>" directly. Both test case #1 and #2 in `LoadAgentDcmdTest.run()` run ok on static JDK with the change:

Commands:
Test case #1: `JVMTI.agent_load libinstrument.so agent.jar`
Test case #2: `JVMTI.agent_load libinstrument.so "agent.jar=foo=bar"`

Additional notes/considerations:

1. I notice [JDKToolFinder.getJDKTool()](https://github.com/openjdk/jdk/blob/80ff7b9c9406c7845ecb3bc40910e92ccdd23ff2/test/lib/jdk/test/lib/JDKToolFinder.java#L41) is used by the test to find the `jcmd` tool. `JDKToolFinder.getJDKTool()` looks for the requested tool in both `test.jdk` and `compile.jdk`. When running the jtreg test on static JDK, it's able to locate the `jcmd` from `compile.jdk` even though the static JDK binary (`test.jdk`) does not provide the tool. For tools used by jtreg tests at runtime, how about change to always do that?

2. From https://docs.oracle.com/en/java/javase/21/docs/specs/man/jcmd.html:

JVMTI.agent_load [arguments]
Loads JVMTI native agent.
  Impact: Low
arguments:
  library path: Absolute path of the JVMTI agent to load. (STRING, no default value)
  agent option: (Optional) Option string to pass the agent. (STRING, no default value)

The command spec requires the absolute path of the JVMTI agent for the `library path` argument. On static JDK, if the agent library is built-in (statically linked), passing the shared library name works and allows the VM to find the built-in agent. There would be no need to specify the absolute path. Please see  https://bugs.openjdk.org/browse/JDK-8353938?focusedId=14767737&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14767737 for more details.

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

Commit messages:
 - Replace "so" with Platform.sharedLibraryExt().
 - Change LoadAgentDcmdTest.getLibInstrumentPath() to return "libinstrument.so" directly without locating the shared library if running on static JDK.

Changes: https://git.openjdk.org/jdk/pull/24497/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24497&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8353938
  Stats: 6 lines in 1 file changed: 6 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/24497.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24497/head:pull/24497

PR: https://git.openjdk.org/jdk/pull/24497


More information about the serviceability-dev mailing list