8329430: MetaspaceShared::preload_and_dump should clear pending exception

Reviewed-by: iklam, stuefe
This commit is contained in:
Calvin Cheung 2024-04-16 17:47:06 +00:00
parent f7c84137b5
commit 76cbe4883b

View File

@ -665,10 +665,12 @@ void MetaspaceShared::preload_and_dump() {
if (PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())) {
log_error(cds)("Out of memory. Please run with a larger Java heap, current MaxHeapSize = "
SIZE_FORMAT "M", MaxHeapSize/M);
CLEAR_PENDING_EXCEPTION;
MetaspaceShared::unrecoverable_writing_error();
} else {
log_error(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(),
java_lang_String::as_utf8_string(java_lang_Throwable::message(PENDING_EXCEPTION)));
CLEAR_PENDING_EXCEPTION;
MetaspaceShared::unrecoverable_writing_error("VM exits due to exception, use -Xlog:cds,exceptions=trace for detail");
}
}