Ernest Friedman-Hill wrote:
Abhishek Lodha wrote:
let MyObject class not be in the classpath and let its superclass be in the classpath. This way MyObject will be loaded by custom class loader and superclass(MySuperObjectClass) will be loaded by system class loader. This way will I be able to cast?
That is correct, if your classloader properly delegates to the system class loader.
Is there any particular reason you wrote your own classloader, rather than simply using URLClassLoader?
Jeff Verdegan wrote:
Abhishek Lodha wrote:
SOP(MyObject.class.getClassLoader()); //This return system class loader Why? when this class has already been loaded by my custom class loader.
MyObject is on your classpath, so the your classloader delegates up to the System classloader to load it. Any class to be loaded by your classloader must NOT be in your classpath.