In HotSpot JVM java.lang.Classloader
class has a Vector of all classes loaded by this classloader. And so all classes are held in memory as long as their's classloader is alive. In IBM JVM J9's java.lang.Classloader there is no such field. At least I was unable to find one. So my questions are:
Where does IBM JVM's classloaders hold class cache?
If differs from the point above: what hard-references classes in IBM JVM, thus preventing from unloading?
Looking at the code of my IBM JVM it seems that java.lang.ClassLoader
is an abstract class, so it will be implemented somewhere. Using the debugger I found that is a synthetic class called sun.misc.Launcher$AppClassLoader
.
Then, to retrieve a class there is a native methodprivate native Class findLoadedClassImpl(String className);
so it seems the caching is done outside Java, in a native method.
At the beginning of loadClass
method I see:
// Ask the VM to look in its cache.
Class loadedClass = findLoadedClass(className);
then it checks whether loadedClass
is null, and if so tries to use the parent clasloader.
So, I'd say that, unless the method is overridden by the inheriting classloader, caching happens outside Java, in some native component of IBM VM.
The IBM J9 JVM has no PermGen on Heap and stores Classes in native memory. You can use -Xdump to generate a javacore.* file, it will contain a list of all classloaders and classes.
BTW: Java8 will do a similiar thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With