RFR: 8302491: NoClassDefFoundError omits the original cause of an error [v4]
David Holmes
dholmes at openjdk.org
Mon Feb 27 02:10:05 UTC 2023
On Fri, 24 Feb 2023 22:18:54 GMT, Ilarion Nakonechnyy <inakonechnyy at openjdk.org> wrote:
>> The proposed approach added a new function for getting the cause of an exception -`java_lang_Throwable::get_cause_simple `, that gets called within `InstanceKlass::add_initialization_error` if an old one `java_lang_Throwable::get_cause_with_stack_trace` didn't succeed because of an exception during the VM call. The simple function doesn't call the VM for getting a stack trace but fills in any other information about an exception.
>>
>> Besides that, the discovering information about an exception was added to `ConstantPoolCacheEntry::save_and_throw_indy_exc` function.
>>
>> Jtreg for reproducing the issue also was added to the commit.
>> The commit was tested with tier1 tests.
>
> Ilarion Nakonechnyy has updated the pull request incrementally with four additional commits since the last revision:
>
> - reverting changes in cpCache.cpp
> - Redesigned get_cause as create_initialization_error.
> Corrected naming in testcase
> - jcheck corrections
> - Removed VM.compMode from test
Please see [JDK-8048190](https://bugs.openjdk.org/browse/JDK-8048190) for why we do not record the original cause in the initialization error table directly.
You cannot guarantee 100% to be able to save the initialization error for later use with the `NoClassDefFoundError` as that requires creating an instance of `ExceptionInInitializerError` with the desired data, to be stored in the initialization error table. There are a number of things that can go wrong trying to create the EIIE instance. The main one is that trying to get the stacktrace can throw an exception. So this PR should simply handle that case: ignore any exception from getting the stacktrace and save the EIIE without it. If creating the EIIE itself throws an exception then we just have to abandon the attempt to save the initialization error - as we have nothing to save.
Thanks
-------------
Changes requested by dholmes (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12566
More information about the hotspot-dev
mailing list