Skip to content

CAUTION: This site hosts draft documentation for the next release. For published content of the latest release, visit www.eclipse.org/openj9/docs

-XX:[+|-]EnableDynamicAgentLoading

This option enables or disables the dynamic loading of agents into a running VM.

Syntax

    -XX:[+|-]EnableDynamicAgentLoading
Setting Effect Default
-XX:+EnableDynamicAgentLoading Enable yes
-XX:-EnableDynamicAgentLoading Disable

Explanation

With the Attach API, your application can connect to a running VM and load an agent dynamically into that VM to run tasks. Some libraries misuse the Attach API to dynamically load an agent to run tasks without the approval of the application owner.

You can disable the dynamic loading of the agents into a VM after startup with the -XX:-EnableDynamicAgentLoading option.

Start of content that applies to Java 21 (LTS) and later For Java™ 21 and later, the following warnings are issued when the agents are loaded dynamically into a running VM after startup without specifying the -XX:+EnableDynamicAgentLoading option. These warnings are not issued if the same agents were loaded before either by using the command-line options or an earlier dynamic loading.

WARNING: A {Java,JVM TI} agent has been loaded dynamically (file:/u/bob/agent.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release

These warnings are issued only once for the same agent when the -XX:+EnableDynamicAgentLoading option is not specified.

If the -XX:+EnableDynamicAgentLoading option is set, all agents that are dynamically loaded are considered as approved by the application owner, and therefore, no warnings are issued.

Eclipse OpenJ9™ supported operating systems other than AIX® have APIs to determine whether the same agent was loaded before or not, even if an agent is loaded with a platform-independent name or an absolute path to the platform-dependent library.

AIX systems cannot detect whether an agent was previously loaded or not if the agent was loaded through a platform-independent name or an absolute path to the platform-dependent library. Therefore, on AIX systems, warnings are issued each time an agent is loaded dynamically through the Attach API (VirtualMachine.loadAgentLibrary(agent)) even if the same agent was loaded before through the command-line option (-agentpath:/Absolute/Path/to/agentLibrary) at startup.

A fix to restrict this display of multiple warnings on loading the same agent will be available in a later version of OpenJ9. End of content that applies to Java 21 (LTS) and later

See also