I’m confused that how an object instance loaded by the other classloader can be accessed without the ClassCastExcepion being thrown except for using reflection?
It seems that using JndiObjectFactoryBean is a better idea,but I donot understand.
Is there anyone Can make me clear?
Thanks very much.
I’m confused that how an object instance loaded by the other classloader can be
Share
The only way (apart from reflection) is to always use an interface type to interact with the class; e.g.
The interface
Imust loaded by a common ancestor classloader ofl1andl2. And assuming that these classloaders (l1andl2) actually loaded the classes, you cannot cast eitherc1orc2toC.