8243290: Improve diagnostic messages for class verification and redefinition failures

Reviewed-by: coleenp, hseigel, sspitsyn
This commit is contained in:
Poonam Bajaj 2020-06-12 12:51:32 +00:00
parent 1b64fb2063
commit ac4603144d
2 changed files with 19 additions and 2 deletions

View File

@ -134,8 +134,15 @@ void Verifier::trace_class_resolution(Klass* resolve_class, InstanceKlass* verif
void Verifier::log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS) {
if (HAS_PENDING_EXCEPTION) {
st->print("Verification for %s has", klassName);
st->print_cr(" exception pending %s ",
oop message = java_lang_Throwable::message(PENDING_EXCEPTION);
if (message != NULL) {
char* ex_msg = java_lang_String::as_utf8_string(message);
st->print_cr(" exception pending '%s %s'",
PENDING_EXCEPTION->klass()->external_name(), ex_msg);
} else {
st->print_cr(" exception pending %s ",
PENDING_EXCEPTION->klass()->external_name());
}
} else if (exception_name != NULL) {
st->print_cr("Verification for %s failed", klassName);
}

View File

@ -1308,10 +1308,20 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) {
the_class->link_class(THREAD);
if (HAS_PENDING_EXCEPTION) {
Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
log_info(redefine, class, load, exceptions)("link_class exception: '%s'", ex_name->as_C_string());
oop message = java_lang_Throwable::message(PENDING_EXCEPTION);
if (message != NULL) {
char* ex_msg = java_lang_String::as_utf8_string(message);
log_info(redefine, class, load, exceptions)("link_class exception: '%s %s'",
ex_name->as_C_string(), ex_msg);
} else {
log_info(redefine, class, load, exceptions)("link_class exception: '%s'",
ex_name->as_C_string());
}
CLEAR_PENDING_EXCEPTION;
if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
return JVMTI_ERROR_OUT_OF_MEMORY;
} else if (ex_name == vmSymbols::java_lang_NoClassDefFoundError()) {
return JVMTI_ERROR_INVALID_CLASS;
} else {
return JVMTI_ERROR_INTERNAL;
}