Integrated: 8353938: hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java fails on static JDK
Jiangli Zhou
jiangli at openjdk.org
Wed Apr 9 17:50:42 UTC 2025
On Tue, 8 Apr 2025 02:25:58 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: faacbd96
Author: Jiangli Zhou <jiangli at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/faacbd96a3dc1116f3af590439585844ff8048a1
Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
8353938: hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java fails on static JDK
Reviewed-by: alanb
-------------
PR: https://git.openjdk.org/jdk/pull/24497
More information about the serviceability-dev
mailing list