Getting a list of all Java classroom classes used from all JVMs?

This question goes a little further than my previous question:

Getting a list of all Java classes used from all JVMs?

Now I need to know the physical location from which these classes are loaded. I checked the jcmd help for other commands but it didn't work for me. I also cannot find it in jvisualvm, but there is no information either. Can anyone help me?

EDIT: This is my situation: my company has different customized java (jars) projects for which we can control whether it starts or stops. We can control this in our own build web interface. Each of these processes gets a process identifier (PID) at startup and then runs in the background.

My need: I need a list of all loaded classes by every running PID java process. I already have it jcmd <pid> GC.class_histogram

, but this only contains a list of the classes that are being loaded. I also need the information from which the classes are actually loaded (this is the jar, the location on the filesystem).

+3


source to share


1 answer


Classes are loaded from a method java.lang.ClassLoader's

loadClass(String name)

, which in turn calls the method . Typically a custom ClassLoader will override the method to get the class definition using a specific protocol and location.It may be that the classes are loaded from the database or from the network, the location of which can be dynamically generated. This way you will never know the location of all Java classes. The best example is AppletClassLoader, which loads classes from a network stream or from a remote location. findClass(String name)

findClass

Bootstrap ClassLoader

- core library package such as rt.jar

presented in the JRE lib folder

Extension ClassLoader

- jar files present in ext folder or as specified in environment variable for ext



System ClassLoader

- Application classpath or as specified in environment variable for classpath or via JVM startup argument parameter for -cp or -classpath

CustomClassLader

- according to the loading policy of the classLoader (mainly defined by the method findClass()

)

+1


source







All Articles