From e2223f0613d53e89e11af587dc3d41a25ffd6849 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Wed, 19 Jul 2023 11:15:51 -0700 Subject: [PATCH] Change java_lang_Throwable::create_initialization_error to create a 'char *' message without using a Symbol. --- src/hotspot/share/classfile/javaClasses.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 4a595435bcac6..e0e492c2ec65c 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -2760,16 +2760,25 @@ Handle java_lang_Throwable::create_initialization_error(JavaThread* current, Han // symbolic stacktrace of 'throwable'. assert(throwable.not_null(), "shouldn't be"); - // Now create the message from the original exception and thread name. - Symbol* message = java_lang_Throwable::detail_message(throwable()); ResourceMark rm(current); + char *message = nullptr; + { + PreserveExceptionMark pm(current); + oop detailed_message = java_lang_Throwable::message(throwable()); + Handle message_handle(current, detailed_message); + if (detailed_message != nullptr) { + message = java_lang_String::as_platform_dependent_str(message_handle, current); + } + } + + // Now create the message from the original exception and thread name. stringStream st; st.print("Exception %s%s ", throwable()->klass()->name()->as_klass_external_name(), message == nullptr ? "" : ":"); if (message == nullptr) { st.print("[in thread \"%s\"]", current->name()); } else { - st.print("%s [in thread \"%s\"]", message->as_C_string(), current->name()); + st.print("%s [in thread \"%s\"]", message, current->name()); } Symbol* exception_name = vmSymbols::java_lang_ExceptionInInitializerError();