@@ -569,13 +569,16 @@ bool ConstantPool::resolve_class_constants(TRAPS) {
569569 return true ;
570570}
571571
572- Symbol* ConstantPool::exception_message (constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception) {
572+ const char * ConstantPool::exception_message (constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception) {
573+ // Note: caller needs ResourceMark
574+
573575 // Dig out the detailed message to reuse if possible
574- Symbol* message = java_lang_Throwable::detail_message (pending_exception);
575- if (message != NULL ) {
576- return message ;
576+ const char * msg = java_lang_Throwable::message_as_utf8 (pending_exception);
577+ if (msg != NULL ) {
578+ return msg ;
577579 }
578580
581+ Symbol* message = NULL ;
579582 // Return specific message for the tag
580583 switch (tag.value ()) {
581584 case JVM_CONSTANT_UnresolvedClass:
@@ -594,16 +597,16 @@ Symbol* ConstantPool::exception_message(constantPoolHandle this_oop, int which,
594597 ShouldNotReachHere ();
595598 }
596599
597- return message;
600+ return message != NULL ? message-> as_C_string () : NULL ;
598601}
599602
600603void ConstantPool::throw_resolution_error (constantPoolHandle this_oop, int which, TRAPS) {
601- Symbol* message = NULL ;
604+ ResourceMark rm (THREAD);
605+ const char * message = NULL ;
602606 Symbol* error = SystemDictionary::find_resolution_error (this_oop, which, &message);
603607 assert (error != NULL && message != NULL , " checking" );
604608 CLEAR_PENDING_EXCEPTION;
605- ResourceMark rm;
606- THROW_MSG (error, message->as_C_string ());
609+ THROW_MSG (error, message);
607610}
608611
609612// If resolution for Class, MethodHandle or MethodType fails, save the exception
@@ -622,7 +625,9 @@ void ConstantPool::save_and_throw_exception(constantPoolHandle this_oop, int whi
622625 // and OutOfMemoryError, etc, or if the thread was hit by stop()
623626 // Needs clarification to section 5.4.3 of the VM spec (see 6308271)
624627 } else if (this_oop->tag_at (which).value () != error_tag) {
625- Symbol* message = exception_message (this_oop, which, tag, PENDING_EXCEPTION);
628+ ResourceMark rm (THREAD);
629+
630+ const char * message = exception_message (this_oop, which, tag, PENDING_EXCEPTION);
626631 SystemDictionary::add_resolution_error (this_oop, which, error, message);
627632 this_oop->tag_at_put (which, error_tag);
628633 } else {
0 commit comments