Add further details to ClassCastException message when casting the class failed because of mismatching class loaders.
Currently the message of the ClassCastException has the following format:
"caster_class cannot be cast to target_class"
This message is sufficient if the caster_class and the target_class are not identical, target_class is no interface implemented by caster_class or target_class is no super class of caster_class.
However the ClassCastException may also be thrown when these requirements are met but the caster_class and the target_class have been loaded by different class loaders.
This enhancement intends to add additional information to the ClassCastException message, when caster_class and target_class have been loaded by different class loaders but otherwise meet all requirements for a class cast.
After JDK-8169559 class cast message now says:
class java.sql.Time cannot be cast to class Derived (java.sql.Time is in module java.sql of loader 'platform'; Derived is in unnamed module of loader 'app')
or
class p4.c4 cannot be cast to class java.lang.String (p4.c4 is in unnamed module of loader 'MyClassLoader' @<id>; java.lang.String is in module java.base of loader 'bootstrap'