--- old/src/hotspot/share/prims/whitebox.cpp 2020-02-25 17:42:02.000000000 -0500 +++ new/src/hotspot/share/prims/whitebox.cpp 2020-02-25 17:42:02.000000000 -0500 @@ -71,6 +71,7 @@ #include "runtime/jniHandles.inline.hpp" #include "runtime/os.hpp" #include "runtime/sweeper.hpp" +#include "runtime/synchronizer.hpp" #include "runtime/thread.hpp" #include "runtime/threadSMR.hpp" #include "runtime/vm_version.hpp" @@ -463,6 +464,12 @@ WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o)) if (UseG1GC) { + if (AsyncDeflateIdleMonitors) { + // AsyncDeflateIdleMonitors needs to know when System.gc() or + // the equivalent is called so any special clean up can be done + // at a safepoint, e.g., TestHumongousClassLoader.java. + ObjectSynchronizer::set_is_special_deflation_requested(true); + } G1CollectedHeap* g1h = G1CollectedHeap::heap(); if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) { g1h->collect(GCCause::_wb_conc_mark); @@ -1418,6 +1425,12 @@ WB_END WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) + if (AsyncDeflateIdleMonitors) { + // AsyncDeflateIdleMonitors needs to know when System.gc() or + // the equivalent is called so any special clean up can be done + // at a safepoint, e.g., TestHumongousClassLoader.java. + ObjectSynchronizer::set_is_special_deflation_requested(true); + } Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true); Universe::heap()->collect(GCCause::_wb_full_gc); #if INCLUDE_G1GC