ClassLoader !_NEWLINE_!Casting
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alok_Gupta
Posted On:   Thursday, July 12, 2001 04:03 AM

			

MyClassLoader cl = new MyClassLoader()


Object o;


Class c;


c = cl.loadClass("ABC");

o = c.newInstance();


((ABC)o).someClassMethod();



Why does the casting in the last line of the Code fails?

Re: ClassLoader !_NEWLINE_!Casting

Posted By:   John_Mitchell  
Posted On:   Thursday, July 12, 2001 12:18 PM

Re: ClassLoader !_NEWLINE_!Casting

Posted By:   Luigi_Viggiano  
Posted On:   Thursday, July 12, 2001 04:10 AM

Because it is loaded from a different classloader: you'll have ABC class inside system class loader, that is "logically distinct" from the ABC loaded by the one loaded by MyClassLoader. Try to specifying the parent on MyClassLoader passing the SystemClassLoader.
About | Sitemap | Contact