@@ -803,13 +803,16 @@ void ConstantPool::resolve_string_constants_impl(const constantPoolHandle& this_
803
803
}
804
804
}
805
805
806
- static Symbol* exception_message (const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) {
806
+ static const char * exception_message (const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) {
807
+ // Note: caller needs ResourceMark
808
+
807
809
// Dig out the detailed message to reuse if possible
808
- Symbol* message = java_lang_Throwable::detail_message (pending_exception);
809
- if (message != nullptr ) {
810
- return message ;
810
+ const char * msg = java_lang_Throwable::message_as_utf8 (pending_exception);
811
+ if (msg != nullptr ) {
812
+ return msg ;
811
813
}
812
814
815
+ Symbol* message = nullptr ;
813
816
// Return specific message for the tag
814
817
switch (tag.value ()) {
815
818
case JVM_CONSTANT_UnresolvedClass:
@@ -832,49 +835,48 @@ static Symbol* exception_message(const constantPoolHandle& this_cp, int which, c
832
835
ShouldNotReachHere ();
833
836
}
834
837
835
- return message;
838
+ return message != nullptr ? message-> as_C_string () : nullptr ;
836
839
}
837
840
838
- static void add_resolution_error (const constantPoolHandle& this_cp, int which,
841
+ static void add_resolution_error (JavaThread* current, const constantPoolHandle& this_cp, int which,
839
842
constantTag tag, oop pending_exception) {
840
843
844
+ ResourceMark rm (current);
841
845
Symbol* error = pending_exception->klass ()->name ();
842
846
oop cause = java_lang_Throwable::cause (pending_exception);
843
847
844
848
// Also dig out the exception cause, if present.
845
849
Symbol* cause_sym = nullptr ;
846
- Symbol * cause_msg = nullptr ;
850
+ const char * cause_msg = nullptr ;
847
851
if (cause != nullptr && cause != pending_exception) {
848
852
cause_sym = cause->klass ()->name ();
849
- cause_msg = java_lang_Throwable::detail_message (cause);
853
+ cause_msg = java_lang_Throwable::message_as_utf8 (cause);
850
854
}
851
855
852
- Symbol * message = exception_message (this_cp, which, tag, pending_exception);
856
+ const char * message = exception_message (this_cp, which, tag, pending_exception);
853
857
SystemDictionary::add_resolution_error (this_cp, which, error, message, cause_sym, cause_msg);
854
858
}
855
859
856
860
857
861
void ConstantPool::throw_resolution_error (const constantPoolHandle& this_cp, int which, TRAPS) {
858
862
ResourceMark rm (THREAD);
859
- Symbol * message = nullptr ;
863
+ const char * message = nullptr ;
860
864
Symbol* cause = nullptr ;
861
- Symbol * cause_msg = nullptr ;
865
+ const char * cause_msg = nullptr ;
862
866
Symbol* error = SystemDictionary::find_resolution_error (this_cp, which, &message, &cause, &cause_msg);
863
867
assert (error != nullptr , " checking" );
864
- const char * cause_str = cause_msg != nullptr ? cause_msg->as_C_string () : nullptr ;
865
868
866
869
CLEAR_PENDING_EXCEPTION;
867
870
if (message != nullptr ) {
868
- char * msg = message->as_C_string ();
869
871
if (cause != nullptr ) {
870
- Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_str );
871
- THROW_MSG_CAUSE (error, msg , h_cause);
872
+ Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_msg );
873
+ THROW_MSG_CAUSE (error, message , h_cause);
872
874
} else {
873
- THROW_MSG (error, msg );
875
+ THROW_MSG (error, message );
874
876
}
875
877
} else {
876
878
if (cause != nullptr ) {
877
- Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_str );
879
+ Handle h_cause = Exceptions::new_exception (THREAD, cause, cause_msg );
878
880
THROW_CAUSE (error, h_cause);
879
881
} else {
880
882
THROW (error);
@@ -896,7 +898,7 @@ void ConstantPool::save_and_throw_exception(const constantPoolHandle& this_cp, i
896
898
// and OutOfMemoryError, etc, or if the thread was hit by stop()
897
899
// Needs clarification to section 5.4.3 of the VM spec (see 6308271)
898
900
} else if (this_cp->tag_at (which).value () != error_tag) {
899
- add_resolution_error (this_cp, which, tag, PENDING_EXCEPTION);
901
+ add_resolution_error (THREAD, this_cp, which, tag, PENDING_EXCEPTION);
900
902
// CAS in the tag. If a thread beat us to registering this error that's fine.
901
903
// If another thread resolved the reference, this is a race condition. This
902
904
// thread may have had a security manager or something temporary.
0 commit comments