i'm writing a custom classloader, i'have set it to be the default classloader by using the parameter
-Djava.system.class.loader=MyClassLoader
Most of the classes are loaded by my classloader, but some classes not, why? This classes are into an external jar file.
UPDATE Here an example
public class Main{
public static void main(String[] args) {
try{
// A simple class loader, ovveride loadClass
// method and print in stdout the name of the class loaded.
MyClassLoader classLoader=new MyClassLoader(MyClassLoader.class.getClassLoader());
Class init=classLoader.loadClass("Initializer");
Object instance=init.newInstance();
init.getMethod("init").invoke(instance);
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
public class A{
public A() {
System.out.println("Im A");
}
}
public class Initializer {
public void init() {
A a=new A();
}
}
The problem is: I expect that class A are loaded by my class loader, but this is does not happen, why?
UPDATE
Anyway, i want to load ALL my classes with my class loader, becouse i want to encrypt class code and decrypt it at runtime. So, how can i use my class loader as default class loader for ALL my classes?
Thanks.