RFR: 6895: Agent Instrumentation fails to emit events when the instrumented class has a different/custom ClassLoader [v2]
Marcus Hirt
hirt at openjdk.java.net
Tue Oct 27 21:22:18 UTC 2020
On Tue, 27 Oct 2020 18:39:25 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.
>
> Joshua Matsuoka has updated the pull request incrementally with two additional commits since the last revision:
>
> - Fixing copyright header
> - Fixing formatting issues
Marked as reviewed by hirt (Lead).
-------------
PR: https://git.openjdk.java.net/jmc/pull/142
More information about the jmc-dev
mailing list