diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 87f60debc14..ea0647fd518 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -2450,8 +2450,8 @@ static inline intptr_t* thaw_internal(JavaThread* thread, const Continuation::th intptr_t* const sp = thw.thaw(kind); assert(is_aligned(sp, frame::frame_alignment), ""); - // All the frames have been thawed so we know they don't hold any monitors - assert(thread->held_monitor_count() == 0, "Must be"); + // All or part of the frames have been thawed so we know they don't hold any monitors except JNI monitors. + assert(thread->held_monitor_count() == thread->jni_monitor_count(), "Must be"); #ifdef ASSERT intptr_t* sp0 = sp; diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/GetOwnedMonitorInfoTest.java b/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/GetOwnedMonitorInfoTest.java index 80ca790a11d..420f1cedaca 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/GetOwnedMonitorInfoTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/GetOwnedMonitorInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @bug 8185164 8320515 + * @bug 8185164 8320515 8334085 * @summary Checks that a contended monitor does not show up in the list of owned monitors. * 8320515 piggy-backs on this test and injects an owned monitor with a dead object, and checks that that monitor isn't exposed to GetOwnedMonitorInfo. @@ -86,6 +86,9 @@ public class GetOwnedMonitorInfoTest { System.out.println("Thread doing JNI call: " + Thread.currentThread().getName()); + // Extra unmount helps to reproduce 8334085. + // Two sub-sequential thaws are needed in that scenario. + Thread.yield(); jniMonitorEnterAndLetObjectDie(); }