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

Joshua Matsuoka jmatsuoka at openjdk.java.net
Tue Oct 27 18:39:25 UTC 2020


> 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

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

Changes:
  - all: https://git.openjdk.java.net/jmc/pull/142/files
  - new: https://git.openjdk.java.net/jmc/pull/142/files/06f15a98..76cfaa57

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jmc&pr=142&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jmc&pr=142&range=00-01

  Stats: 37 lines in 3 files changed: 2 ins; 12 del; 23 mod
  Patch: https://git.openjdk.java.net/jmc/pull/142.diff
  Fetch: git fetch https://git.openjdk.java.net/jmc pull/142/head:pull/142

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


More information about the jmc-dev mailing list