From c3f934b7ea9b9708ed0bfc035bb0bacd973447be Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Thu, 29 Jan 2026 09:45:21 +0100 Subject: [PATCH] 8366659: Extra check before posting the waited event. --- src/hotspot/share/runtime/objectMonitor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index 45c82d5ba45..144533cd959 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -1938,8 +1938,10 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { { ThreadBlockInVM tbvm(current, true); } - - JvmtiExport::post_monitor_waited(current, this, ret == OS_TIMEOUT); + // Re-check the condition as the monitor waited events can be disabled whilst thread was suspended. + if (JvmtiExport::should_post_monitor_waited()) { + JvmtiExport::post_monitor_waited(current, this, ret == OS_TIMEOUT); + } } if (wait_event.should_commit()) {