We do have a cache (Map
) with objects of Class TestClass
. Another classloader initializes/loads TestClass
at runtime again, so below code will threw a ClassCastException
:
TestClass obj1 = (TestClass)map.get("key"); // throws a ClassCastException
ClassCastException when casting to the same class
Alright, I do understand this issue up to this point.
So, I was trying to find background information why is TestClass.class
not equals TestClass.class
. I assume that the different classloader set a different id to the ReferenceType? Anyone able to explain the background to me?
Best page I've found: http://www.objectsource.com/j2eechapters/Ch21-ClassLoaders_and_J2EE.htm