RFR: 8204955: Extend ClassCastException message
rene.schuenemann at gmail.com
Fri Jun 15 05:31:42 UTC 2018
I agree the message is confusing. I saw your proposal for the new
standardized output when I put this change for review.
I think it is best to wait for the outcome of that and revise this change
upon the new output format, or even discard this change if it is not needed
On Thu, Jun 14, 2018 at 10:45 PM, Lois Foltan <lois.foltan at oracle.com>
>> On 6/14/2018 3:41 AM, René Schünemann wrote:
>>> 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.
>>> "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.
>>> "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
>>> for the new exception message.
>>> Thank you,
>> Hi Rene,
>> Thank you for your work to improve ClassCastException. I do have some
>> concerns about this change:
>> - In runtime/sharedRuntime.cpp - please do not add another method to
>> obtain the class loader's name. Work is underway to consolidate how within
>> the VM a class loader's name is obtained. See the work for JDK-8202605,
>> currently out for review and can be followed at
>> - Work is also underway to standardize the output of certain error
>> messages like IllegalAccessError, ClassCastException, etc. Please see the
>> current proposal at http://mail.openjdk.java.net/p
>> ipermail/hotspot-runtime-dev/2018-June/028425.html. The error changes
>> you have made do not follow this proposed format.
>> - I'm not sure the added verbiage to ClassCastException is helpful. I
>> actually find "Loaded by OtherLoader, but needed class loader MyLoader."
>> quite confusing. How does this help diagnose the issue that caused the
>> - It is not clear what tests you have run for this change. This
>> information should be included in any RFR request.
>> Thank you,
More information about the hotspot-dev