Fight the Future

Java言語とJVM、そしてJavaエコシステム全般にまつわること

How can I get a web application classloader in Java Agent's method agentmain()

I implement Java Agent which transform classes of a web application running in an application server.

To do so, I need a web application classloader which load these classes.

I know Instrument#getAllLoadedClasses() method.

But this method returns Class array, so I retrieve the Class loaded by web application class loader by Class name etc.

I think this is not good code.

Is there another way to get a web application classloader in Java Agent?