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.
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.
luck, db
There are no new questions, but there may be new answers.
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.
Abhishek Lodha wrote:
MyObject is in classpath but I am overriding the default way classloaders are created. I am not delegating the request to load the class system class loader but I am loading it from my classloader.
Abhishek Lodha wrote:
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.
Presumably calling loadClass() on an already loaded class does nothing.
[quuote]
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.
Is there any particular reason you wrote your own classloader, rather than simply using URLClassLoader?
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?
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.
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|