title: Java extend Application Classloader?
body: <p><strong><em>Problem:</em></strong>
  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: <strong>from where</strong>. For example: stack.overflow.ClassA in jar StackOverFlowJar.jar. </p>
  
  <p><strong><em>My thoughts:</em></strong> 
  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. </p>
  
  <p>My CustomClassLoader extends ClassLoader, and I can see it loads classes such as:</p>
  
  <pre><code>java.lang.Class
  java.lang.Thread
  java.lang.ThreadGroup
  </code></pre>
  
  <p>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:</p>
  
  <p><img src="https://i.stack.imgur.com/YtyL2.png" alt="test">
  source: <a href="http://javarevisited.blogspot.nl/2012/12/how-classloader-works-in-java.html" rel="nofollow noreferrer">http://javarevisited.blogspot.nl/2012/12/how-classloader-works-in-java.html</a></p>
  
  <p>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.</p>
  
  <p><strong>My question:</strong>
  Is it possible to extend the Application ClassLoader and the extension ClassLoader? Or is there perhaps another workaround for my problem?</p>
  
  <p>Thank you very much in advance!</p>