--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp Thu Jul 19 11:15:38 2018 -0700
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp Thu Jul 19 12:55:24 2018 -0700
@@ -435,6 +435,7 @@
IRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, char* name, oopDesc* obj))
+ // Produce the error message first because note_trap can safepoint
ResourceMark rm(thread);
const char* klass_name = obj->klass()->external_name();
// lookup exception klass
@@ -448,20 +449,22 @@
IRT_END
IRT_ENTRY(void, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException(JavaThread* thread, arrayOopDesc* a, jint index))
+ // Produce the error message first because note_trap can safepoint
+ ResourceMark rm(thread);
+ stringStream ss;
+ ss.print("Index %d out of bounds for length %d", index, a->length());
+
if (ProfileTraps) {
note_trap(thread, Deoptimization::Reason_range_check, CHECK);
}
- ResourceMark rm(thread);
- stringStream ss;
- ss.print("Index %d out of bounds for length %d", index, a->length());
-
THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
IRT_END
IRT_ENTRY(void, InterpreterRuntime::throw_ClassCastException(
JavaThread* thread, oopDesc* obj))
+ // Produce the error message first because note_trap can safepoint
ResourceMark rm(thread);
char* message = SharedRuntime::generate_class_cast_message(
thread, obj->klass());