RFR: 8302491: NoClassDefFoundError omits the original cause of an error [v3]
Ilarion Nakonechnyy
inakonechnyy at openjdk.org
Fri Feb 24 22:18:58 UTC 2023
On Wed, 22 Feb 2023 05:05:30 GMT, David Holmes <dholmes 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 2764:
>
>> 2762: h_cause->klass()->external_name());
>> 2763: return Handle();
>> 2764: }
>
> You need to do this whether `with_stack_trace` or not, otherwise you will install the exception from `new_exception` as the initialization error for this class, when in fact it was not the initialization error at all.
I would suggest a correction in this place.
Just because if Java is in a state, when it throws an SOE at JavaCalls::call_virtual(), the most probably that the `Exceptions::new_exception()`, which actually wraps up a call to Java, also throws an SOE.
If I return an empty Handle(), any clues on the cause will be missed from a stacktrace, even one of my testcases shows the following results:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class java.lang.invoke.MethodHandleImpl$AsVarargsCollector
at java.sql/java.sql.DriverManager.ensureDriversInitialized(DriverManager.java:628)
at java.sql/java.sql.DriverManager.getDrivers(DriverManager.java:427)
at jdbc.repro.DriverA.<init>(DriverA.java:22)
at jdbc.repro.DriverRepro.main(DriverRepro.java:12)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class java.lang.invoke.MethodHandleImpl$AsVarargsCollector
... 4 more
-------------
PR: https://git.openjdk.org/jdk/pull/12566
More information about the hotspot-dev
mailing list