8299031: JFR: Clean up jdk.management.jfr

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2022-12-20 12:22:01 +00:00
parent c5a4a7a679
commit 318526b01e
4 changed files with 11 additions and 23 deletions

View File

@ -70,17 +70,15 @@ public final class ConfigurationInfo {
}
private static Map<String, String> createMap(Object o) {
if (o instanceof TabularData) {
TabularData td = (TabularData) o;
if (o instanceof TabularData td) {
Collection<?> values = td.values();
Map<String, String> map = HashMap.newHashMap(values.size());
for (Object value : td.values()) {
if (value instanceof CompositeData) {
CompositeData cdRow = (CompositeData) value;
if (value instanceof CompositeData cdRow) {
Object k = cdRow.get("key");
Object v = cdRow.get("value");
if (k instanceof String && v instanceof String) {
map.put((String) k, (String) v);
if (k instanceof String sk && v instanceof String sv) {
map.put(sk, sv);
}
}
}

View File

@ -88,12 +88,11 @@ public final class EventTypeInfo {
}
private static List<SettingDescriptorInfo> createSettings(Object settings) {
if (settings != null && settings.getClass().isArray()) {
Object[] settingsArray = (Object[]) settings;
if (settings instanceof Object[] settingsArray) {
List<SettingDescriptorInfo> list = new ArrayList<>(settingsArray.length);
for (Object cd : settingsArray) {
if (cd instanceof CompositeData) {
list.add(SettingDescriptorInfo.from((CompositeData) cd));
for (Object element : settingsArray) {
if (element instanceof CompositeData cd) {
list.add(SettingDescriptorInfo.from(cd));
}
}
return Collections.unmodifiableList(list);

View File

@ -106,8 +106,7 @@ public final class RecordingInfo {
durationInSeconds = (long) cd.get("duration");
settings = new LinkedHashMap<>();
Object map = cd.get("settings");
if (map instanceof TabularData) {
TabularData td = (TabularData) map;
if (map instanceof TabularData td) {
List<String> keyNames = td.getTabularType().getIndexNames();
int size = keyNames.size();
for (Object keys : td.keySet()) {
@ -115,8 +114,8 @@ public final class RecordingInfo {
for (int i = 0; i < size; i++) {
String key = keyNames.get(i);
Object value = keyValues[i];
if (value instanceof String) {
settings.put(key, (String) value);
if (value instanceof String s) {
settings.put(key, s);
}
}
}

View File

@ -295,14 +295,6 @@ public final class RemoteRecordingStream implements EventStream {
}
}
private Map<String, String> getRecordingOptions() throws IOException {
try {
return mbean.getRecordingOptions(recordingId);
} catch (Exception e) {
throw new IOException("Could not get recording options: " + e.getMessage(), e);
}
}
/**
* Replaces all settings for this recording stream.
* <p>