diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/EventTypeInfo.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/EventTypeInfo.java index d2b43fd874bcb..15739829ee449 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/EventTypeInfo.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/EventTypeInfo.java @@ -44,7 +44,7 @@ * @since 9 */ public final class EventTypeInfo { - private final List settings; + private final List settingDescriptors; private final long id; private final String name; private final String description; @@ -53,7 +53,7 @@ public final class EventTypeInfo { // package private EventTypeInfo(EventType eventType) { - this.settings = creatingSettingDescriptorInfos(eventType); + this.settingDescriptors = creatingSettingDescriptorInfos(eventType); this.id = eventType.getId(); this.name = eventType.getName(); this.label = eventType.getLabel(); @@ -62,12 +62,20 @@ public final class EventTypeInfo { } private EventTypeInfo(CompositeData cd) { - this.settings = createSettings(cd.get("settings")); + if (cd.containsKey("settings")) { + this.settingDescriptors = createSettingDescriptors(cd.get("settings")); + } else { + this.settingDescriptors = createSettingDescriptors(cd.get("settingDescriptors")); + } this.id = (long) cd.get("id"); this.name = (String) cd.get("name"); this.label = (String) cd.get("label"); this.description = (String) cd.get("description"); - this.categoryNames = createCategoryNames((Object[]) cd.get("category")); + if (cd.containsKey("category")) { + this.categoryNames = createCategoryNames((Object[]) cd.get("category")); + } else { + this.categoryNames = createCategoryNames((Object[]) cd.get("categoryNames")); + } } private static List createCategoryNames(Object[] array) { @@ -87,7 +95,7 @@ private static List creatingSettingDescriptorInfos(EventT return Collections.unmodifiableList(settingDescriptorInfos); } - private static List createSettings(Object settings) { + private static List createSettingDescriptors(Object settings) { if (settings instanceof Object[] settingsArray) { List list = new ArrayList<>(settingsArray.length); for (Object element : settingsArray) { @@ -174,7 +182,7 @@ public String getDescription() { * @see EventType#getSettingDescriptors() */ public List getSettingDescriptors() { - return settings; + return settingDescriptors; } /** @@ -229,11 +237,11 @@ public String toString() { * {@code String} * * - * category + * categoryNames * ArrayType(1, SimpleType.STRING) * * - * settings + * settingDescriptors * {@code javax.management.openmbean.CompositeData[]} whose element type * is the mapped type for {@link SettingDescriptorInfo} as specified in the * {@link SettingDescriptorInfo#from} method. diff --git a/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java b/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java index 7050c0d8a1ca7..001147e8e5ccf 100644 --- a/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java +++ b/test/jdk/jdk/jfr/jmx/info/TestEventTypeInfo.java @@ -42,13 +42,14 @@ * @summary Test for EventTypeInfo * @requires vm.hasJFR * @library /test/lib /test/jdk - * @run main/othervm jdk.jfr.jmx.info.TestEventTypeInfo + * @run main/othervm -Djdk.attach.allowAttachSelf=true -Dcom.sun.management.jmxremote jdk.jfr.jmx.info.TestEventTypeInfo */ public class TestEventTypeInfo { public static void main(String[] args) throws Throwable { FlightRecorder jfr = FlightRecorder.getFlightRecorder(); - FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + long selfPID = JmxHelper.getPID(); + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(selfPID); List typeInfos = bean.getEventTypes(); Map types = new HashMap<>();