RFR: 8302491: NoClassDefFoundError omits the original cause of an error [v3]

David Holmes dholmes at openjdk.org
Wed Feb 22 05:10:31 UTC 2023


On Tue, 21 Feb 2023 15:06:42 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Ilarion Nakonechnyy has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Get rid of redundant code -
>>    merge get_cause_with_stack_trace and get_cause_simple
>>  - Review corrections
>
> src/hotspot/share/classfile/javaClasses.cpp line 2738:
> 
>> 2736: }
>> 2737: 
>> 2738: Handle java_lang_Throwable::get_cause(Handle throwable, bool with_stack_trace, TRAPS) {
> 
> I see, you just reversed the code so it creates the message first, then calls getStackTrace.
> If you change it to not have TRAPS, and use JavaThread* current as the first parameter, then have as the first line to show that the exception isn't propagated out of this function.
> JavaThread* THREAD = current;
> create the message
> { call getStackTrace();
>   if (PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION;
>   else set_stacktrace(); clear_backtrace();
> }
> return h_cause;
> 
> Something like that.  Then the caller doesn't need to check for null or pending exception.

I agree with Coleen's suggestion, it doesn't make sense to return null and have a pending exception when the pending exception will be cleared in the caller anyway. This is a pre-existing issue but while we are here.

-------------

PR: https://git.openjdk.org/jdk/pull/12566


More information about the hotspot-dev mailing list