RFR: 8204955: Extend ClassCastException message
Harold David Seigel
harold.seigel at oracle.com
Thu Jun 14 20:02:46 UTC 2018
Hi Rene,
I'm not sure that adding text such as "Loaded by OtherLoader, but needed
class loader MyLoader" is all that helpful if the first part of the
message already contains the class loader names.
Also, the text implies that the problem is with "OtherLoader" but the
user may actually need to change the type or something else.
Thanks, Harold
On 6/14/2018 3:41 AM, René Schünemann wrote:
> 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