Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,15 @@ private static synchronized void registerDeadlockDetectionEvent() {

private static synchronized void registerSmapEntryEvent() {
log.debug("Initializing smap entry scraping");

// Load JFR Handlers class early, if present (it has been moved and renamed in JDK23+).
// This prevents a deadlock. See https://bugs.openjdk.org/browse/JDK-8371889.
try {
AGENT_CLASSLOADER.loadClass("jdk.jfr.events.Handlers");
} catch (Exception e) {
// Ignore when the class is not found or anything else goes wrong.
}

try {
final Class<?> smapFactoryClass =
AGENT_CLASSLOADER.loadClass(
Expand Down