On Tue, 3 Nov 2026 15:53:16 GMT, Markus Grönlund <[email protected]> wrote:

> Greetings,
> 
> Please review this change to improve JFR’s reporting of JVMTI agents and, for 
> better separation of concerns, the responsibilities and lifetimes of JVMTI 
> agents.
> 
> ## Problem
> 
> Tools commonly reuse `Agent_OnAttach` as a control channel—for example, to 
> start and stop profiling. Previously, each successful startup invocation was 
> counted as a new agent instance, producing duplicate and misleading JFR 
> reporting.
> 
> This change associates reporting with JVMTI environment lifetimes established 
> during agent startup, while separating those lifetimes from library lookup 
> and `Agent_OnUnload` notifications.
> 
> For further details and a before-and-after profiling demonstration, see 
> [JDK-8392584](https://bugs.openjdk.org/browse/JDK-8392584).
> 
> ## Model and responsibilities
> 
> The model separates agent startup from loading its underlying OS library. An 
> agent startup invocation of an entry point may establish a new registered 
> agent instance or simply issue a command to an already existing agent.
> 
> The responsibilities are divided as follows:
> 
> - `JvmtiAgent` represents a startup invocation and holds its identity, JVMTI 
> environment association, startup state, and initialization timing.
> - `JvmtiAgentSet` manages startup attribution, JVMTI environment association 
> and disposal, and the append-only registry of registered JvmtiAgents.
> - `JvmtiResolver` represents shared library-resolution identity and manages 
> native-lookup eligibility and `Agent_OnUnload` registration.
> - `JvmtiAgentLifecycle` handles OS library loading, agent startup entry-point 
> resolution, invocation of startup entry-points, and unload notifications.
> 
> Dynamically loaded OS libraries are identified by their OS handles. 
> Statically linked JvmtiAgents are distinguished by normalized names.
> 
> ## JVMTI environment association and retention
> 
> The first successfully created JVMTI environment on the startup thread is 
> associated with the innermost executing startup invocation. This environment 
> becomes the `JvmtiAgent`'s identity over its lifetime.
> 
> The association has some constraints:
> 
> - Disposing the associated environment does not make the `JvmtiAgent` 
> eligible for reassociation.
> - Additional environments created by an inner startup invocation do not fall 
> through to an outer invocation.
> - Environment creation outside a startup invocation issued by the JVM does 
> not establish a tracked `JvmtiAgent` instance.
> 
> This direct association replaces attribution through callback addresses and 
> hardcoded knowledge of the JPLIS env...

make/hotspot/lib/JvmFeatures.gmk line 97:

> 95:       evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
> 96:       jvmtiClassFileReconstituter.cpp jvmtiTagMapTable.cpp jvmtiAgent.cpp 
> \
> 97:       jvmtiAgentLifecycle.cpp jvmtiAgentSet.cpp jvmtiResolver.cpp 
> jfrJvmtiAgent.cpp jfrJvmtiAgentEvent.cpp

Please break the line for consistent line width.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33700#discussion_r4457609004

Reply via email to