I'm trying to figure out how to unload classes.
However, I wish to be able to figure out what classes are already loaded. How can this be found?
I'm trying to figure out how to unload classes.
However, I wish to be able to figure out what classes are already loaded. How can this be found?
Watch the method getInitiatedClasses:
http://docs.oracle.com/javase/7/docs/api/java/lang/instrument/Instrumentation.html
Only as an alternative to Andres answer you can turn on -verbose:class
and redirect stdout to a file. There we'll get this log
...
[Loaded java.lang.Object from C:\Program Files\Java\jre7\lib\rt.jar]
[Loaded java.io.Serializable from C:\Program Files\Java\jre7\lib\rt.jar]
[Loaded java.lang.Comparable from C:\Program Files\Java\jre7\lib\rt.jar]
...
We can extract a class name, load it
Class cls = Class.forName(className);
if cls.getClassLoader()
returns null
it was loaded with bootstrap class loader.