Try setting custom class loaders's parent as null
super(null) in the constructor.
A is loaded by custom loader.
then A instantiates B.
So the custom loader will get a chance to load B (since it loaded A in the first place).
So as per classloader's delegation model,
custom loader will first delegate the loading of class B to the parent which turns out to be null.
so our loader gets a chance to load B as well.
But our findClass needs to have the logic to find
B.
public class TestLoader extends ClassLoader{
public TestLoader(){
super(null);
}
public Class findClass(){
}
}
try this and let us know if it works.
karthik.
Originally posted by rakesh nagar:
Hi There,
I have the same problem. I have written a custom class loader. It is working fine. But the Objects which are created in the Object loaded by my custom classloader. for example i have instantiate class A using my classloader and in the Object A i am instantiate an object of class B. The problem is that the class B is loaded by default Java class loader. How can i avoid it.
waiting for ur reply
thanks & regards
Rakesh