I have two ClassLoaders which loads the same class. So, obviously these can't cast to one another. But I need to access an object created in the other ClassLoader.
I have access to both ClassLoaders. How can I use that object in the other class? I don't need to cast the object to match to the current ClassLoader.
But the issue is that the returned object's type is Object. So, I have to cast down that object to access some methods. How can I do that? Normal cast like the following causes ClassCastException, which I already know.
Mojo mojo = (Mojo) descriptor.getMojo();
descriptor#getMojo() returns an object of type Mojo but the method returns Object. How can do this?
Let me know if you need further info.
I've read all the theories about classloading, but none has specified a proper solution for this.