4444import jdk .jfr .EventType ;
4545import jdk .jfr .Name ;
4646import jdk .jfr .Period ;
47+ import jdk .jfr .SettingControl ;
4748import jdk .jfr .ValueDescriptor ;
4849import jdk .jfr .internal .consumer .RepositoryFiles ;
4950import jdk .jfr .internal .event .EventConfiguration ;
@@ -59,7 +60,6 @@ public final class MetadataRepository {
5960 private final Map <String , EventControl > nativeControls = LinkedHashMap .newHashMap (150 );
6061 private final SettingsManager settingsManager = new SettingsManager ();
6162 private final HiddenWait threadSleeper = new HiddenWait ();
62- private Constructor <EventConfiguration > cachedEventConfigurationConstructor ;
6363 private boolean staleMetadata = true ;
6464 private boolean unregistered ;
6565 private long lastUnloaded = -1 ;
@@ -103,7 +103,7 @@ public synchronized List<EventType> getRegisteredEventTypes() {
103103 List <EventType > eventTypes = new ArrayList <>(configurations .size () + nativeEventTypes .size ());
104104 for (EventConfiguration ec : configurations ) {
105105 if (ec .isRegistered ()) {
106- eventTypes .add (ec .getEventType ());
106+ eventTypes .add (ec .eventType ());
107107 }
108108 }
109109 for (EventType t : nativeEventTypes .values ()) {
@@ -117,15 +117,15 @@ public synchronized List<EventType> getRegisteredEventTypes() {
117117 public synchronized EventType getEventType (Class <? extends jdk .internal .event .Event > eventClass ) {
118118 EventConfiguration ec = getConfiguration (eventClass , false );
119119 if (ec != null && ec .isRegistered ()) {
120- return ec .getEventType ();
120+ return ec .eventType ();
121121 }
122122 throw new IllegalStateException ("Event class " + eventClass .getName () + " is not registered" );
123123 }
124124
125125 public synchronized void unregister (Class <? extends Event > eventClass ) {
126126 EventConfiguration configuration = getConfiguration (eventClass , false );
127127 if (configuration != null ) {
128- configuration .getPlatformEventType ().setRegistered (false );
128+ configuration .platformEventType ().setRegistered (false );
129129 }
130130 // never registered, ignore call
131131 }
@@ -147,14 +147,14 @@ public synchronized EventType register(Class<? extends jdk.internal.event.Event>
147147 PlatformEventType pe = findMirrorType (eventClass );
148148 configuration = makeConfiguration (eventClass , pe , dynamicAnnotations , dynamicFields );
149149 }
150- configuration .getPlatformEventType ().setRegistered (true );
151- TypeLibrary .addType (configuration .getPlatformEventType ());
150+ configuration .platformEventType ().setRegistered (true );
151+ TypeLibrary .addType (configuration .platformEventType ());
152152 if (JVM .isRecording ()) {
153- settingsManager .setEventControl (configuration .getEventControl (), true , JVM .counterTime ());
153+ settingsManager .setEventControl (configuration .eventControl (), true , JVM .counterTime ());
154154 settingsManager .updateRetransform (Collections .singletonList ((eventClass )));
155155 }
156156 setStaleMetadata ();
157- return configuration .getEventType ();
157+ return configuration .eventType ();
158158 }
159159
160160 private PlatformEventType findMirrorType (Class <? extends jdk .internal .event .Event > eventClass ) throws InternalError {
@@ -179,20 +179,6 @@ private EventConfiguration getConfiguration(Class<? extends jdk.internal.event.E
179179 return JVMSupport .getConfiguration (eventClass );
180180 }
181181
182- private EventConfiguration newEventConfiguration (EventType eventType , EventControl ec ) {
183- try {
184- if (cachedEventConfigurationConstructor == null ) {
185- var argClasses = new Class <?>[] { EventType .class , EventControl .class };
186- Constructor <EventConfiguration > c = EventConfiguration .class .getDeclaredConstructor (argClasses );
187- c .setAccessible (true );
188- cachedEventConfigurationConstructor = c ;
189- }
190- return cachedEventConfigurationConstructor .newInstance (eventType , ec );
191- } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
192- throw new InternalError (e );
193- }
194- }
195-
196182 private EventConfiguration makeConfiguration (Class <? extends jdk .internal .event .Event > eventClass , PlatformEventType pEventType , List <AnnotationElement > dynamicAnnotations , List <ValueDescriptor > dynamicFields ) throws InternalError {
197183 SecuritySupport .addInternalEventExport (eventClass );
198184 if (pEventType == null ) {
@@ -226,12 +212,12 @@ private EventConfiguration makeConfiguration(Class<? extends jdk.internal.event.
226212 }
227213 EventType eventType = PrivateAccess .getInstance ().newEventType (pEventType );
228214 EventControl ec = new EventControl (pEventType , eventClass );
229- EventConfiguration configuration = newEventConfiguration ( eventType , ec );
230- PlatformEventType pe = configuration . getPlatformEventType ( );
231- pe .setRegistered (true );
215+ SettingControl [] settings = ec . getSettingControls (). toArray ( new SettingControl [ 0 ] );
216+ EventConfiguration configuration = new EventConfiguration ( pEventType , eventType , ec , settings , eventType . getId () );
217+ pEventType .setRegistered (true );
232218 // If class is instrumented or should not be instrumented, mark as instrumented.
233- if (JVM .isInstrumented (eventClass ) || !JVMSupport .shouldInstrument (pe .isJDK (), pe .getName ())) {
234- pe .setInstrumented ();
219+ if (JVM .isInstrumented (eventClass ) || !JVMSupport .shouldInstrument (pEventType .isJDK (), pEventType .getName ())) {
220+ pEventType .setInstrumented ();
235221 }
236222 JVMSupport .setConfiguration (eventClass , configuration );
237223 return configuration ;
@@ -254,7 +240,7 @@ public synchronized List<EventControl> getEventControls() {
254240 for (Class <? extends jdk .internal .event .Event > clazz : eventClasses ) {
255241 EventConfiguration eh = JVMSupport .getConfiguration (clazz );
256242 if (eh != null ) {
257- controls .add (eh .getEventControl ());
243+ controls .add (eh .eventControl ());
258244 }
259245 }
260246 return controls ;
0 commit comments