RFR: 8048190: NoClassDefFoundError omits original ExceptionInInitializerError [v10]

Ioi Lam iklam at openjdk.java.net
Wed Aug 11 20:49:29 UTC 2021


On Wed, 11 Aug 2021 16:32:51 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> This is a change to save the class initialization error stack trace in a hashtable and return it as the cause when NoClassDefFoundError is thrown.  The first commit is a more limited version of this that just changes the message, by adding to the message string.  The second commit is getting and saving the stack trace for the original exception, and using the thread in the message.  See CR for more details about how the message looks.
>> 
>> Tested with tier1-3 tests on 3 platforms.  Tier 4-6 in progress (all but two done and passed).
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fix typo in EIIE message.

Looks good overall. Some minor nits.

src/hotspot/share/oops/instanceKlass.cpp line 1022:

> 1020: 
> 1021: void InstanceKlass::add_initialization_error(Handle exception, TRAPS) {
> 1022:   bool created = false;

Since this function will never throw, by our new convention, it should not be declared TRAPS, and the thread parameter should not be the last.

src/hotspot/share/oops/instanceKlass.cpp line 1028:

> 1026:   // this would be still be helpful.
> 1027:   Handle cause = java_lang_Throwable::get_cause_with_stack_trace(exception, THREAD);
> 1028:   CLEAR_PENDING_EXCEPTION;

If new exceptions happened inside `get_cause_with_stack_trace`, `cause` will be null here. Maybe proceed to the following only if `cause` is not null?

src/hotspot/share/oops/instanceKlass.cpp line 1109:

> 1107:       ResourceMark rm(THREAD);
> 1108:       Handle cause(THREAD, get_initialization_error(THREAD));
> 1109:       CLEAR_PENDING_EXCEPTION; // ignore any OOM here.

`get_initialization_error()` doesn't throw any error. Is `CLEAR_PENDING_EXCEPTION` really needed here?

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

Changes requested by iklam (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/4996


More information about the hotspot-dev mailing list