44
44
import jdk .jfr .EventType ;
45
45
import jdk .jfr .Name ;
46
46
import jdk .jfr .Period ;
47
+ import jdk .jfr .SettingControl ;
47
48
import jdk .jfr .ValueDescriptor ;
48
49
import jdk .jfr .internal .consumer .RepositoryFiles ;
49
50
import jdk .jfr .internal .event .EventConfiguration ;
@@ -59,7 +60,6 @@ public final class MetadataRepository {
59
60
private final Map <String , EventControl > nativeControls = LinkedHashMap .newHashMap (150 );
60
61
private final SettingsManager settingsManager = new SettingsManager ();
61
62
private final HiddenWait threadSleeper = new HiddenWait ();
62
- private Constructor <EventConfiguration > cachedEventConfigurationConstructor ;
63
63
private boolean staleMetadata = true ;
64
64
private boolean unregistered ;
65
65
private long lastUnloaded = -1 ;
@@ -103,7 +103,7 @@ public synchronized List<EventType> getRegisteredEventTypes() {
103
103
List <EventType > eventTypes = new ArrayList <>(configurations .size () + nativeEventTypes .size ());
104
104
for (EventConfiguration ec : configurations ) {
105
105
if (ec .isRegistered ()) {
106
- eventTypes .add (ec .getEventType ());
106
+ eventTypes .add (ec .eventType ());
107
107
}
108
108
}
109
109
for (EventType t : nativeEventTypes .values ()) {
@@ -117,15 +117,15 @@ public synchronized List<EventType> getRegisteredEventTypes() {
117
117
public synchronized EventType getEventType (Class <? extends jdk .internal .event .Event > eventClass ) {
118
118
EventConfiguration ec = getConfiguration (eventClass , false );
119
119
if (ec != null && ec .isRegistered ()) {
120
- return ec .getEventType ();
120
+ return ec .eventType ();
121
121
}
122
122
throw new IllegalStateException ("Event class " + eventClass .getName () + " is not registered" );
123
123
}
124
124
125
125
public synchronized void unregister (Class <? extends Event > eventClass ) {
126
126
EventConfiguration configuration = getConfiguration (eventClass , false );
127
127
if (configuration != null ) {
128
- configuration .getPlatformEventType ().setRegistered (false );
128
+ configuration .platformEventType ().setRegistered (false );
129
129
}
130
130
// never registered, ignore call
131
131
}
@@ -147,14 +147,14 @@ public synchronized EventType register(Class<? extends jdk.internal.event.Event>
147
147
PlatformEventType pe = findMirrorType (eventClass );
148
148
configuration = makeConfiguration (eventClass , pe , dynamicAnnotations , dynamicFields );
149
149
}
150
- configuration .getPlatformEventType ().setRegistered (true );
151
- TypeLibrary .addType (configuration .getPlatformEventType ());
150
+ configuration .platformEventType ().setRegistered (true );
151
+ TypeLibrary .addType (configuration .platformEventType ());
152
152
if (JVM .isRecording ()) {
153
- settingsManager .setEventControl (configuration .getEventControl (), true , JVM .counterTime ());
153
+ settingsManager .setEventControl (configuration .eventControl (), true , JVM .counterTime ());
154
154
settingsManager .updateRetransform (Collections .singletonList ((eventClass )));
155
155
}
156
156
setStaleMetadata ();
157
- return configuration .getEventType ();
157
+ return configuration .eventType ();
158
158
}
159
159
160
160
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
179
179
return JVMSupport .getConfiguration (eventClass );
180
180
}
181
181
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
-
196
182
private EventConfiguration makeConfiguration (Class <? extends jdk .internal .event .Event > eventClass , PlatformEventType pEventType , List <AnnotationElement > dynamicAnnotations , List <ValueDescriptor > dynamicFields ) throws InternalError {
197
183
SecuritySupport .addInternalEventExport (eventClass );
198
184
if (pEventType == null ) {
@@ -226,12 +212,12 @@ private EventConfiguration makeConfiguration(Class<? extends jdk.internal.event.
226
212
}
227
213
EventType eventType = PrivateAccess .getInstance ().newEventType (pEventType );
228
214
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 );
232
218
// 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 ();
235
221
}
236
222
JVMSupport .setConfiguration (eventClass , configuration );
237
223
return configuration ;
@@ -254,7 +240,7 @@ public synchronized List<EventControl> getEventControls() {
254
240
for (Class <? extends jdk .internal .event .Event > clazz : eventClasses ) {
255
241
EventConfiguration eh = JVMSupport .getConfiguration (clazz );
256
242
if (eh != null ) {
257
- controls .add (eh .getEventControl ());
243
+ controls .add (eh .eventControl ());
258
244
}
259
245
}
260
246
return controls ;
0 commit comments