1 /* 2 * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package jdk.jfr.internal; 26 27 import java.util.Map; 28 import java.util.concurrent.ConcurrentHashMap; 29 30 import jdk.jfr.events.DeserializationEvent; 31 import jdk.jfr.events.ErrorThrownEvent; 32 import jdk.jfr.events.ExceptionStatisticsEvent; 33 import jdk.jfr.events.ExceptionThrownEvent; 34 import jdk.jfr.events.FileForceEvent; 35 import jdk.jfr.events.FileReadEvent; 36 import jdk.jfr.events.FileWriteEvent; 37 import jdk.jfr.events.ProcessStartEvent; 38 import jdk.jfr.events.SecurityPropertyModificationEvent; 39 import jdk.jfr.events.SecurityProviderServiceEvent; 40 import jdk.jfr.events.SerializationMisdeclarationEvent; 41 import jdk.jfr.events.SocketReadEvent; 42 import jdk.jfr.events.SocketWriteEvent; 43 import jdk.jfr.events.TLSHandshakeEvent; 44 import jdk.jfr.events.ThreadSleepEvent; 45 import jdk.jfr.events.VirtualThreadEndEvent; 46 import jdk.jfr.events.VirtualThreadStartEvent; 47 import jdk.jfr.events.VirtualThreadSubmitFailedEvent; 48 import jdk.jfr.events.X509CertificateEvent; 49 import jdk.jfr.events.X509ValidationEvent; 50 import jdk.jfr.internal.util.Utils; 51 52 /** 53 * This class registers all mirror events. 54 */ 55 final class MirrorEvents { 56 private static final Map<String, Class<? extends MirrorEvent>> mirrorLookup = new ConcurrentHashMap<>(); 57 58 // Add mirror event mapping here. See MirrorEvent class for details. 59 static { 60 register("jdk.internal.event.DeserializationEvent", DeserializationEvent.class); 61 register("jdk.internal.event.FileForceEvent", FileForceEvent.class); 62 register("jdk.internal.event.FileReadEvent", FileReadEvent.class); 63 register("jdk.internal.event.FileWriteEvent", FileWriteEvent.class); 64 register("jdk.internal.event.ProcessStartEvent", ProcessStartEvent.class); 65 register("jdk.internal.event.SecurityPropertyModificationEvent", SecurityPropertyModificationEvent.class); 66 register("jdk.internal.event.SecurityProviderServiceEvent", SecurityProviderServiceEvent.class); 67 register("jdk.internal.event.SerializationMisdeclarationEvent", SerializationMisdeclarationEvent.class); 68 register("jdk.internal.event.SocketReadEvent", SocketReadEvent.class); 69 register("jdk.internal.event.SocketWriteEvent", SocketWriteEvent.class); 70 register("jdk.internal.event.ThreadSleepEvent", ThreadSleepEvent.class); 71 register("jdk.internal.event.TLSHandshakeEvent", TLSHandshakeEvent.class); 72 register("jdk.internal.event.VirtualThreadStartEvent", VirtualThreadStartEvent.class); 73 register("jdk.internal.event.VirtualThreadEndEvent", VirtualThreadEndEvent.class); 74 register("jdk.internal.event.VirtualThreadSubmitFailedEvent", VirtualThreadSubmitFailedEvent.class); 75 register("jdk.internal.event.X509CertificateEvent", X509CertificateEvent.class); 76 register("jdk.internal.event.X509ValidationEvent", X509ValidationEvent.class); 77 register("jdk.internal.event.ErrorThrownEvent", ErrorThrownEvent.class); 78 register("jdk.internal.event.ExceptionStatisticsEvent", ExceptionStatisticsEvent.class); 79 register("jdk.internal.event.ExceptionThrownEvent", ExceptionThrownEvent.class); 80 }; 81 82 private static void register(String eventClassName, Class<? extends MirrorEvent> mirrorClass) { 83 mirrorLookup.put(eventClassName, mirrorClass); 84 } 85 86 static Class<? extends MirrorEvent> find(Class<? extends jdk.internal.event.Event> eventClass) { 87 return find(Utils.isJDKClass(eventClass), eventClass.getName()); 88 } 89 90 static Class<? extends MirrorEvent> find(boolean bootClassLoader, String name) { 91 if (bootClassLoader) { 92 return mirrorLookup.get(name); 93 } 94 return null; 95 } 96 }