I\'ve been trying to set up a custom classloader that intercepts classes to print out which classes are being loaded into the application. The classloader looks like this
<
If you do
System.out.println( p.getClass().getClassLoader() );
you'll see that p
's classloader isn't your MyClassLoader bcl
. It was actually loaded by bcl
's parent, the system class loader.
When PythonInterpreter
loads its dependent classes, it'll use its actual class loader, the system classloader, not your bcl
, so your interception isn't reached.
To solve the problem, your classloader can't delegate to its parent, it has to actually load the classes by itself.
For that you can subclass URLClassLoader
(steal the URLs from the system classloader).