Integrated: 6895: Agent Instrumentation fails to emit events when the instrumented class has a different/custom ClassLoader

Joshua Matsuoka jmatsuoka at openjdk.java.net
Wed Oct 28 16:27:42 UTC 2020


On Tue, 27 Oct 2020 14:22:58 GMT, Joshua Matsuoka <jmatsuoka at openjdk.org> wrote:

> Hi,
> 
> This PR addresses JMC-6895, which made it so that the agent instrumentation would silently fail and not emit events when a class being instrumented was loaded by a custom classloader and its' methods were reflectively invoked.
> 
> The following is the sequence of events that caused this bug:
> 
> - When the class was initially loaded by the AppClassLoader the agent instruments it as we'd expect
> - When the class was later loaded by the custom classloader, that classloader's loadClass call chain would lead to the agent being called to transform again
> -- Since the transform had already been done once it was marked as complete and would not do anything
> -- When the code for the class was later run, it would not emit the events due to a ClassNotFoundException on the injected event classes as they were not visible to the custom classloader
> 
> This patch resolves this and makes sure instrumentation is done with the custom classloader and that the event classes are visible to it. I've also included an integration test replicating the behavior that caused the bug.

This pull request has now been integrated.

Changeset: 31619d6d
Author:    Joshua Matsuoka <jmatsuoka at openjdk.org>
URL:       https://git.openjdk.java.net/jmc/commit/31619d6d
Stats:     229 lines in 5 files changed: 213 ins; 9 del; 7 mod

6895: Agent Instrumentation fails to emit events when the instrumented class has a different/custom ClassLoader

Reviewed-by: hirt

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

PR: https://git.openjdk.java.net/jmc/pull/142


More information about the jmc-dev mailing list