> 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 > > This design keeps each agent’s state separate from shared library details, > startup tracking, and entry-point calls. > > - `JvmtiAgent` stores the agent’s identity, options, a reference to the > `JvmtiAgentLibrary`, and a link to the JVMTI environment. Startup, JVMTI > environment association, and timing have separate state models. > - `JvmtiAgentManager` creates new `JvmtiAgent` objects, manages agent startup > and selects agents for retention or discarding. It handles JVMTI environment > disposal and `VMInit` timing, agent iteration, and diagnostic info. > - `JvmtiAgentLibrary` represents a loaded OS library. It includes the > library’s handle, static-agent identity, file path, and resolution of JVMTI > entry points. More than one agent can use the same library. > - `JvmtiAgentLibraryManager` loads and tracks `JvmtiAgentLibrary` objects and > manages native lookups and `Agent_OnUnload` eligibility. The identity and > lifetime of a library are separate from any `JvmtiAgent`. > - `JvmtiAgentInvoker` resolves and invokes exported JVMTI entry points like > `Agent_OnLoad` and `Agent_OnAttach`, handling thread-state changes and > results. It also handles legacy `XRUN` conversion and runtime agent > attachment timing. > - `JvmtiAgentStartupRequest` is a stack-allocated scope helper. It links > JVMTI environment creation to the most recent startup request for a thread. > On scope end, it removes the startup request under its scope. Its purpose is > to allow nested startup calls. > > ## 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 associat...
Markus Grönlund has updated the pull request incrementally with one additional commit since the last revision: streamlining ------------- Changes: - all: https://git.openjdk.org/jdk/pull/33700/files - new: https://git.openjdk.org/jdk/pull/33700/files/1e48e46e..61124960 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=33700&range=03 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33700&range=02-03 Stats: 670 lines in 16 files changed: 169 ins; 367 del; 134 mod Patch: https://git.openjdk.org/jdk/pull/33700.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33700/head:pull/33700 PR: https://git.openjdk.org/jdk/pull/33700
