From d7b075864c3191835014564179feefbd4021a7ca Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Wed, 8 Nov 2023 13:01:53 -0500 Subject: [PATCH 1/5] add test to verify mirror events --- .../oracle/svm/test/jfr/TestMirrorEvents.java | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java new file mode 100644 index 000000000000..f6c01a75f4b1 --- /dev/null +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2023, Red Hat Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.svm.test.jfr; + +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import org.junit.Test; + +import java.nio.file.Path; +import java.util.List; + +import com.oracle.svm.test.jfr.utils.JfrFileParser; + +import static org.junit.Assert.assertTrue; + +/** + * This test checks that JFR mirror events have been set up correctly. If mirror events have not + * been set up correctly, then mirrored events will have incorrect metadata. This test verifies that + * metadata. + */ +public class TestMirrorEvents extends JfrRecordingTest { + + @Test + public void test() throws Throwable { + Recording recording = new Recording(); + + // Disable all events except Mirror Events. + recording.enable("jdk.ThreadSleep"); + recording.enable("jdk.VirtualThreadStart"); + recording.enable("jdk.VirtualThreadEnd"); + + Path path = createTempJfrFile(); + recording.setDestination(path); + recording.start(); + + // Generate some mirror event emissions. + Runnable eventEmitter = () -> { + try { + Thread.sleep(100); + } catch (Exception e) { + throw new RuntimeException(e); + } + }; + + VirtualStressor.execute(1, eventEmitter); + + recording.stop(); + recording.close(); + + // Some standard checks + JfrFileParser parser = new JfrFileParser(path); + parser.verify(); + + boolean foundSleepEvent = false; + boolean foundVthreadStartEvent = false; + boolean foundVthreadEndEvent = false; + + List recordedEvents = RecordingFile.readAllEvents(path); + assertTrue("No events were recorded.", recordedEvents.size() > 0); + + for (RecordedEvent event : recordedEvents) { + EventType eventType = event.getEventType(); + + assertTrue("Mirror event metadata not applied correctly.", !eventType.getName().equals("jdk.internal.event.ThreadSleepEvent") && + !eventType.getName().equals("jdk.internal.event.VirtualThreadStartEvent") && !eventType.getName().equals("jdk.internal.event.VirtualThreadEndEvent")); + + System.out.println(eventType.getName()); + if (eventType.getName().equals("jdk.ThreadSleep") && eventType.getCategoryNames().contains("Java Application") && eventType.getLabel().equals("Java Thread Sleep")) { + foundSleepEvent = true; + } + if (eventType.getName().equals("jdk.VirtualThreadStart") && eventType.getCategoryNames().contains("Java Application") && eventType.getLabel().equals("Virtual Thread Start")) { + foundVthreadStartEvent = true; + } + if (eventType.getName().equals("jdk.VirtualThreadEnd") && eventType.getCategoryNames().contains("Java Application") && eventType.getLabel().equals("Virtual Thread End")) { + foundVthreadEndEvent = true; + } + } + + // The only events recorded should be the mirror events we explicitly enabled. If they were + // not found, it means their metadata is incorrect. + assertTrue("Mirror events containing correct metadata not found.", foundSleepEvent && foundVthreadStartEvent && foundVthreadEndEvent); + } + +} From fdb68e86bf1db8223fea262b5f82376d6383569a Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Wed, 8 Nov 2023 13:03:27 -0500 Subject: [PATCH 2/5] minor cleanup --- .../src/com/oracle/svm/test/jfr/TestMirrorEvents.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java index f6c01a75f4b1..e64874b1962e 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java @@ -50,7 +50,7 @@ public class TestMirrorEvents extends JfrRecordingTest { public void test() throws Throwable { Recording recording = new Recording(); - // Disable all events except Mirror Events. + // Disable all events except mirror events. recording.enable("jdk.ThreadSleep"); recording.enable("jdk.VirtualThreadStart"); recording.enable("jdk.VirtualThreadEnd"); @@ -59,7 +59,7 @@ public void test() throws Throwable { recording.setDestination(path); recording.start(); - // Generate some mirror event emissions. + // Generate some event emissions. Runnable eventEmitter = () -> { try { Thread.sleep(100); @@ -90,7 +90,6 @@ public void test() throws Throwable { assertTrue("Mirror event metadata not applied correctly.", !eventType.getName().equals("jdk.internal.event.ThreadSleepEvent") && !eventType.getName().equals("jdk.internal.event.VirtualThreadStartEvent") && !eventType.getName().equals("jdk.internal.event.VirtualThreadEndEvent")); - System.out.println(eventType.getName()); if (eventType.getName().equals("jdk.ThreadSleep") && eventType.getCategoryNames().contains("Java Application") && eventType.getLabel().equals("Java Thread Sleep")) { foundSleepEvent = true; } From 599c30e7dfd6cdc67d13e1c562273e8a517c8602 Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Wed, 8 Nov 2023 13:54:00 -0500 Subject: [PATCH 3/5] add substitution --- .../Target_jdk_jfr_internal_MirrorEvents.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java new file mode 100644 index 000000000000..b8a255263b45 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2023, Red Hat Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jfr; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.annotate.TargetElement; +import com.oracle.svm.core.jdk.JDK22OrLater; + +@TargetClass(className = "jdk.jfr.internal.MirrorEvents", onlyWith = {JDK22OrLater.class, HasJfrSupport.class}) +final class Target_jdk_jfr_internal_MirrorEvents { + + @Alias // + @TargetElement(onlyWith = JDK22OrLater.class) // + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) // + private static Class[] mirrorEventClasses = new Class[]{}; +} From 3e6f74a95e3b9c1731bacd875ecb0e9febd1ec0c Mon Sep 17 00:00:00 2001 From: Christian Haeubl Date: Fri, 10 Nov 2023 10:02:19 +0100 Subject: [PATCH 4/5] Changed MirrorEvents test case. --- .../Target_jdk_jfr_internal_MirrorEvents.java | 4 +- .../oracle/svm/test/jfr/AbstractJfrTest.java | 8 +-- .../oracle/svm/test/jfr/JfrRecordingTest.java | 10 +++- .../oracle/svm/test/jfr/JfrStreamingTest.java | 6 +- .../oracle/svm/test/jfr/TestMirrorEvents.java | 55 ++++++------------- 5 files changed, 39 insertions(+), 44 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java index b8a255263b45..c61de3337de4 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java @@ -25,6 +25,8 @@ */ package com.oracle.svm.core.jfr; +import static com.oracle.svm.core.annotate.RecomputeFieldValue.Kind.FromAlias; + import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; @@ -36,6 +38,6 @@ final class Target_jdk_jfr_internal_MirrorEvents { @Alias // @TargetElement(onlyWith = JDK22OrLater.class) // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) // + @RecomputeFieldValue(kind = FromAlias, isFinal = true) // private static Class[] mirrorEventClasses = new Class[]{}; } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/AbstractJfrTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/AbstractJfrTest.java index c42f5f13ef4a..14d0608e6051 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/AbstractJfrTest.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/AbstractJfrTest.java @@ -86,22 +86,22 @@ protected static Configuration getDefaultConfiguration() throws Throwable { return Configuration.getConfiguration("default"); } - protected static void checkRecording(EventValidator validator, Path path, JfrRecordingState state) throws Throwable { + protected static void checkRecording(EventValidator validator, Path path, JfrRecordingState state, boolean validateTestedEventsOnly) throws Throwable { JfrFileParser parser = new JfrFileParser(path); parser.verify(); - List events = getEvents(path, state.testedEvents); + List events = getEvents(path, state.testedEvents, validateTestedEventsOnly); checkEvents(events, state.testedEvents); if (validator != null) { validator.validate(events); } } - private static List getEvents(Path path, String[] testedEvents) throws IOException { + private static List getEvents(Path path, String[] testedEvents, boolean validateTestedEventsOnly) throws IOException { /* Only return events that are in the list of tested events. */ ArrayList result = new ArrayList<>(); for (RecordedEvent event : RecordingFile.readAllEvents(path)) { - if (isTestedEvent(event, testedEvents)) { + if (!validateTestedEventsOnly || isTestedEvent(event, testedEvents)) { result.add(event); } } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrRecordingTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrRecordingTest.java index 21ea50946e41..231b14bdf8ac 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrRecordingTest.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrRecordingTest.java @@ -57,6 +57,10 @@ protected Recording startRecording(String[] events) throws Throwable { return startRecording(events, config, null, createTempJfrFile()); } + protected Recording startRecording(String[] events, Configuration config) throws Throwable { + return startRecording(events, config, null, createTempJfrFile()); + } + protected Recording startRecording(String[] events, Configuration config, Map settings) throws Throwable { return startRecording(events, config, settings, createTempJfrFile()); } @@ -95,10 +99,14 @@ private static void enableEvents(Recording recording, String[] events) { } public void stopRecording(Recording recording, EventValidator validator) throws Throwable { + stopRecording(recording, validator, true); + } + + public void stopRecording(Recording recording, EventValidator validator, boolean validateTestedEventsOnly) throws Throwable { recording.stop(); recording.close(); JfrRecordingState state = recordingStates.get(recording); - checkRecording(validator, recording.getDestination(), state); + checkRecording(validator, recording.getDestination(), state, validateTestedEventsOnly); } } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrStreamingTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrStreamingTest.java index a78ec6da3b33..e7e8ead4172c 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrStreamingTest.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/JfrStreamingTest.java @@ -75,12 +75,16 @@ protected RecordingStream startStream(String[] events) throws Throwable { } protected void stopStream(RecordingStream stream, EventValidator validator) throws Throwable { + stopStream(stream, validator, true); + } + + protected void stopStream(RecordingStream stream, EventValidator validator, boolean validateTestedEventsOnly) throws Throwable { Path jfrFile = createTempJfrFile(); stream.dump(jfrFile); closeStream(stream); JfrStreamState state = streamStates.get(stream); - checkRecording(validator, jfrFile, state); + checkRecording(validator, jfrFile, state, validateTestedEventsOnly); } private void startStream(RecordingStream stream) throws InterruptedException { diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java index e64874b1962e..c26c5ed35c4c 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestMirrorEvents.java @@ -26,18 +26,15 @@ package com.oracle.svm.test.jfr; -import jdk.jfr.EventType; -import jdk.jfr.Recording; -import jdk.jfr.consumer.RecordedEvent; -import jdk.jfr.consumer.RecordingFile; -import org.junit.Test; +import static org.junit.Assert.assertTrue; -import java.nio.file.Path; import java.util.List; -import com.oracle.svm.test.jfr.utils.JfrFileParser; +import org.junit.Test; -import static org.junit.Assert.assertTrue; +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; /** * This test checks that JFR mirror events have been set up correctly. If mirror events have not @@ -48,18 +45,9 @@ public class TestMirrorEvents extends JfrRecordingTest { @Test public void test() throws Throwable { - Recording recording = new Recording(); - - // Disable all events except mirror events. - recording.enable("jdk.ThreadSleep"); - recording.enable("jdk.VirtualThreadStart"); - recording.enable("jdk.VirtualThreadEnd"); - - Path path = createTempJfrFile(); - recording.setDestination(path); - recording.start(); + String[] events = new String[]{"jdk.ThreadSleep", "jdk.VirtualThreadStart", "jdk.VirtualThreadEnd"}; + Recording recording = startRecording(events); - // Generate some event emissions. Runnable eventEmitter = () -> { try { Thread.sleep(100); @@ -70,26 +58,20 @@ public void test() throws Throwable { VirtualStressor.execute(1, eventEmitter); - recording.stop(); - recording.close(); - - // Some standard checks - JfrFileParser parser = new JfrFileParser(path); - parser.verify(); + stopRecording(recording, TestMirrorEvents::validateEvents); + } + /** + * If the mirror event metadata is incorrect, we will see events with the wrong event name, e.g. + * "jdk.internal.event.ThreadSleepEvent" instead of "jdk.ThreadSleep". + */ + private static void validateEvents(List unfilteredEvents) { boolean foundSleepEvent = false; boolean foundVthreadStartEvent = false; boolean foundVthreadEndEvent = false; - List recordedEvents = RecordingFile.readAllEvents(path); - assertTrue("No events were recorded.", recordedEvents.size() > 0); - - for (RecordedEvent event : recordedEvents) { + for (RecordedEvent event : unfilteredEvents) { EventType eventType = event.getEventType(); - - assertTrue("Mirror event metadata not applied correctly.", !eventType.getName().equals("jdk.internal.event.ThreadSleepEvent") && - !eventType.getName().equals("jdk.internal.event.VirtualThreadStartEvent") && !eventType.getName().equals("jdk.internal.event.VirtualThreadEndEvent")); - if (eventType.getName().equals("jdk.ThreadSleep") && eventType.getCategoryNames().contains("Java Application") && eventType.getLabel().equals("Java Thread Sleep")) { foundSleepEvent = true; } @@ -101,9 +83,8 @@ public void test() throws Throwable { } } - // The only events recorded should be the mirror events we explicitly enabled. If they were - // not found, it means their metadata is incorrect. - assertTrue("Mirror events containing correct metadata not found.", foundSleepEvent && foundVthreadStartEvent && foundVthreadEndEvent); + assertTrue(foundSleepEvent); + assertTrue(foundVthreadStartEvent); + assertTrue(foundVthreadEndEvent); } - } From 1da907f8a9f6109264d25acec7aee8d74dcff227 Mon Sep 17 00:00:00 2001 From: Christian Haeubl Date: Fri, 10 Nov 2023 14:55:00 +0100 Subject: [PATCH 5/5] Add documentation and remove class Target_jdk_jfr_internal_MirrorEvents. --- .../Target_jdk_jfr_internal_MirrorEvents.java | 43 ------------------- .../svm/hosted/jfr/JfrEventSubstitution.java | 7 ++- 2 files changed, 6 insertions(+), 44 deletions(-) delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java deleted file mode 100644 index c61de3337de4..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_MirrorEvents.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2023, 2023, Red Hat Inc. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jfr; - -import static com.oracle.svm.core.annotate.RecomputeFieldValue.Kind.FromAlias; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK22OrLater; - -@TargetClass(className = "jdk.jfr.internal.MirrorEvents", onlyWith = {JDK22OrLater.class, HasJfrSupport.class}) -final class Target_jdk_jfr_internal_MirrorEvents { - - @Alias // - @TargetElement(onlyWith = JDK22OrLater.class) // - @RecomputeFieldValue(kind = FromAlias, isFinal = true) // - private static Class[] mirrorEventClasses = new Class[]{}; -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventSubstitution.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventSubstitution.java index 01001920809e..9d6e27c95553 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventSubstitution.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventSubstitution.java @@ -158,7 +158,12 @@ private Boolean initEventClass(ResolvedJavaType eventType) throws RuntimeExcepti eventType.initialize(); if (JavaVersionUtil.JAVA_SPEC < 22) { - // It is crucial that mirror events are registered before the actual events. + /* + * It is crucial that mirror events are registered before the actual events. + * Starting with JDK 22, this is no longer necessary because + * MetadataRepository.register(...) handles that directly, see code that uses + * MirrorEvents.find(...). + */ Class mirrorEventClass = mirrorEventMapping.get(newEventClass.getName()); if (mirrorEventClass != null) { registerMirror.invoke(null, mirrorEventClass);