diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index b8b408b4133..2107b186c5e 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -3144,7 +3144,10 @@ JvmtiEnv::RawMonitorEnter(JvmtiRawMonitor * rmonitor) { // in thread.cpp. JvmtiPendingMonitors::enter(rmonitor); } else { - rmonitor->raw_enter(Thread::current()); + Thread* thread = Thread::current(); + // 8266889: raw_enter changes Java thread state, needs WXWrite + MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); + rmonitor->raw_enter(thread); } return JVMTI_ERROR_NONE; } /* end RawMonitorEnter */ @@ -3176,6 +3179,8 @@ JvmtiEnv::RawMonitorExit(JvmtiRawMonitor * rmonitor) { jvmtiError JvmtiEnv::RawMonitorWait(JvmtiRawMonitor * rmonitor, jlong millis) { Thread* thread = Thread::current(); + // 8266889: raw_wait changes Java thread state, needs WXWrite + MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); int r = rmonitor->raw_wait(millis, thread); switch (r) {