@@ -767,13 +767,16 @@ void ConstantPool::resolve_string_constants_impl(const constantPoolHandle& this_
767767 }
768768}
769769
770- static Symbol* exception_message (const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) {
770+ static const char * exception_message (const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) {
771+ // Note: caller needs ResourceMark
772+
771773 // Dig out the detailed message to reuse if possible
772- Symbol* message = java_lang_Throwable::detail_message (pending_exception);
773- if (message != NULL ) {
774- return message ;
774+ const char * msg = java_lang_Throwable::message_as_utf8 (pending_exception);
775+ if (msg != nullptr ) {
776+ return msg ;
775777 }
776778
779+ Symbol* message = nullptr ;
777780 // Return specific message for the tag
778781 switch (tag.value ()) {
779782 case JVM_CONSTANT_UnresolvedClass:
@@ -796,49 +799,48 @@ static Symbol* exception_message(const constantPoolHandle& this_cp, int which, c
796799 ShouldNotReachHere ();
797800 }
798801
799- return message;
802+ return message != nullptr ? message-> as_C_string () : nullptr ;
800803}
801804
802- static void add_resolution_error (const constantPoolHandle& this_cp, int which,
805+ static void add_resolution_error (JavaThread* current, const constantPoolHandle& this_cp, int which,
803806 constantTag tag, oop pending_exception) {
807+ ResourceMark rm (current);
804808
805809 Symbol* error = pending_exception->klass ()->name ();
806810 oop cause = java_lang_Throwable::cause (pending_exception);
807811
808812 // Also dig out the exception cause, if present.
809813 Symbol* cause_sym = NULL ;
810- Symbol * cause_msg = NULL ;
814+ const char * cause_msg = nullptr ;
811815 if (cause != NULL && cause != pending_exception) {
812816 cause_sym = cause->klass ()->name ();
813- cause_msg = java_lang_Throwable::detail_message (cause);
817+ cause_msg = java_lang_Throwable::message_as_utf8 (cause);
814818 }
815819
816- Symbol * message = exception_message (this_cp, which, tag, pending_exception);
820+ const char * message = exception_message (this_cp, which, tag, pending_exception);
817821 SystemDictionary::add_resolution_error (this_cp, which, error, message, cause_sym, cause_msg);
818822}
819823
820824
821825void ConstantPool::throw_resolution_error (const constantPoolHandle& this_cp, int which, TRAPS) {
822826 ResourceMark rm (THREAD);
823- Symbol * message = NULL ;
827+ const char * message = NULL ;
824828 Symbol* cause = NULL ;
825- Symbol * cause_msg = NULL ;
829+ const char * cause_msg = NULL ;
826830 Symbol* error = SystemDictionary::find_resolution_error (this_cp, which, &message, &cause, &cause_msg);
827831 assert (error != NULL , " checking" );
828- const char * cause_str = cause_msg != NULL ? cause_msg->as_C_string () : NULL ;
829832
830833 CLEAR_PENDING_EXCEPTION;
831834 if (message != NULL ) {
832- char * msg = message->as_C_string ();
833835 if (cause != NULL ) {
834- Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_str );
835- THROW_MSG_CAUSE (error, msg , h_cause);
836+ Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_msg );
837+ THROW_MSG_CAUSE (error, message , h_cause);
836838 } else {
837- THROW_MSG (error, msg );
839+ THROW_MSG (error, message );
838840 }
839841 } else {
840842 if (cause != NULL ) {
841- Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_str );
843+ Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_msg );
842844 THROW_CAUSE (error, h_cause);
843845 } else {
844846 THROW (error);
@@ -860,7 +862,7 @@ void ConstantPool::save_and_throw_exception(const constantPoolHandle& this_cp, i
860862 // and OutOfMemoryError, etc, or if the thread was hit by stop()
861863 // Needs clarification to section 5.4.3 of the VM spec (see 6308271)
862864 } else if (this_cp->tag_at (which).value () != error_tag) {
863- add_resolution_error (this_cp, which, tag, PENDING_EXCEPTION);
865+ add_resolution_error (THREAD, this_cp, which, tag, PENDING_EXCEPTION);
864866 // CAS in the tag. If a thread beat us to registering this error that's fine.
865867 // If another thread resolved the reference, this is a race condition. This
866868 // thread may have had a security manager or something temporary.
0 commit comments