5

Is there any tool that connects to a jvm and shows you in real time how classes get loaded in that jvm? I imagine it would make a great jvisualvm plugin..however not finding anything like this makes me wonder if this would be at all feasible? I only found a few references to some seemingly "obscure" tools, strictly related to weblogic or webspere.

Assuming that such a tool is possible, would it be strictly related to a particular container?

Thanks!

teo
  • 1,393
  • 1
  • 15
  • 25
  • see https://stackoverflow.com/questions/2548384/java-get-a-list-of-all-classes-loaded-in-the-jvm – weberjn Jun 05 '19 at 06:32

1 Answers1

1

I realize this doesn't work with a JVM that's already running, but how about java -verbose:class?

If you want to debug classloader issues for a specific class, you can connect with a debugger and set a class loading breakpoint for that class (that's how Eclipse calls them, in IntelliJ you just put a breakpoint on the first line of the class).

Update: Since you mentioned you want to see the classloaders, in theory I guess you could write an agent that calls java.lang.instrument.Instrumentation.getAllLoadedClasses() in agentmain and prints a tree of classes and their classloaders. The problem though is that ClassLoader doesn't have an "identity", so you may get a pretty picture but you still don't have any idea which classloader belongs to which Java EE deployment or OSGi bundle. I guess that's why there aren't that many tools that do it...

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Dan Berindei
  • 7,054
  • 3
  • 41
  • 48
  • 2
    Well, the idea of "visual-classloading" raised precisely from using the "-verbose" option, as this doesn't show you the classloader (from what I know) and you don't really get the "big picture" of the classloading process by using it. Anyway, I guess that the tool from the question would be useful to understand and learn about classloading, rather than troubleshooting. – teo May 12 '11 at 07:37