RFR: 8204955: Extend ClassCastException message

René Schünemann rene.schuenemann at gmail.com
Thu Jun 14 07:41:22 UTC 2018


Hi,

can I please get a review for the following change:

Bug: https://bugs.openjdk.java.net/browse/JDK-8204955
Webrev: http://cr.openjdk.java.net/~simonis/webrevs/2018/8204955

This change adds additional details to the ClassCastException message
when the class cast failed due to non-matching class loaders.

Example:

"MyLoader/m/MyClass cannot be cast to OtherLoader/m/MyClass. Loaded by
OtherLoader, but needed class loader MyLoader."

It is now also checked whether the target class is an extended
interface or super class of the caster class and casting failed due to
non-matching class loaders.

Example:

"MyLoader/m/MyClass cannot be cast to OtherLoader/m/MyInterface. Found
matching interface OtherLoader/m/MyInterface loaded by OtherLoader but
needed class loader MyLoader."

I have added the test
"jdk/test/hotspot/jtreg/runtime/exceptionMsgs/ClassCastException/ClassCastExceptionTest.java"
for the new exception message.


Thank you,
Rene


More information about the hotspot-dev mailing list