Problem: My company has a lot of different jars/existing projects that they run at their customers. For debugging purposes, we would like to generate a log which class every component loads and more specifically: from where. For example: stack.overflow.ClassA in jar StackOverFlowJar.jar.
My thoughts: I have experimented with passing each jar/existing project a custom class loader. This custom class loader could potentially write above information to a file, and delegate the normal flow of class loading to its parent.
My CustomClassLoader extends ClassLoader, and I can see it loads classes such as:
java.lang.Class
java.lang.Thread
java.lang.ThreadGroup
etc etc, all the standard java classes from the core library. These classes do reach my CustomClassLoader. However, as can be seen by next image:
source: http://javarevisited.blogspot.nl/2012/12/how-classloader-works-in-java.html
There are multiple ClassLoaders. The Bootstrap ClassLoader (the one I extend with my CustomClassLoader) is only responsible for core libraries. If it can't find a custom created class, it will delegate it back to the Extension ClassLoader. If the Extension ClassLoader can't find it, it will delegate it back to the Application ClassLoader, and I can see in debugging modus, this is indeed the one that loads my custom classes. But it doesn't do so through my CustomClassLoader.
My question: Is it possible to extend the Application ClassLoader and the extension ClassLoader? Or is there perhaps another workaround for my problem?
Thank you very much in advance!