Skip to content

Commit 783cc89

Browse files
committed
Improved support for experimental events
- JFREventType.isExperimental() - correctly marked for JFR9/11 - mentioned in Recording view
1 parent dc01148 commit 783cc89

File tree

6 files changed

+59
-10
lines changed

6 files changed

+59
-10
lines changed

visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericEventType.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,13 +33,17 @@
3333
import org.openjdk.jmc.common.item.IAccessorKey;
3434
import org.openjdk.jmc.common.item.IItem;
3535
import org.openjdk.jmc.common.item.IType;
36+
import org.openjdk.jmc.flightrecorder.messages.internal.Messages;
3637

3738
/**
3839
*
3940
* @author Jiri Sedlacek
4041
*/
4142
final class JFRGenericEventType extends JFREventType {
4243

44+
private static final String EXPERIMENTAL_PREFIX = Messages.getString(Messages.TypeManager_EXPERIMENTAL_TYPE).replace("{0}", "").trim(); // NOI18N
45+
46+
4347
private final long typeId;
4448
private final IType type;
4549
private final String[] category;
@@ -50,8 +54,8 @@ final class JFRGenericEventType extends JFREventType {
5054
this.type = type;
5155
this.category = category;
5256
}
53-
5457

58+
5559
@Override
5660
public long getId() {
5761
return typeId;
@@ -87,6 +91,13 @@ public List<JFRDataDescriptor> getDisplayableDataDescriptors(boolean includeExpe
8791
}
8892

8993

94+
@Override
95+
public boolean isExperimental() {
96+
// TODO: should be turned into regexp and test matching, not startsWith!
97+
return type.getName().startsWith(EXPERIMENTAL_PREFIX);
98+
}
99+
100+
90101
@Override
91102
public int hashCode() {
92103
return type.hashCode();

visualvm/jfr.jdk9/src/org/graalvm/visualvm/jfr/jdk9/model/impl/DisplayableSupport.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
3737
import java.util.Set;
3838
import jdk.jfr.DataAmount;
3939
import jdk.jfr.EventType;
40+
import jdk.jfr.Experimental;
4041
import jdk.jfr.Frequency;
4142
import jdk.jfr.MemoryAddress;
4243
import jdk.jfr.Percentage;
@@ -118,7 +119,8 @@ private ValueDescriptor computeNext() {
118119
}
119120

120121
private boolean isDisplayable(ValueDescriptor descriptor) {
121-
return !ID_STACKTRACE.equals(descriptor.getName());
122+
if (ID_STACKTRACE.equals(descriptor.getName())) return false;
123+
return includeExperimental || !isExperimental(descriptor);
122124
}
123125
};
124126
}
@@ -155,7 +157,10 @@ static JFRDataDescriptor getDataDescriptor(ValueDescriptor descriptor) {
155157
isNumeric = DEFAULT_PROCESSOR.isNumeric(descriptor);
156158
}
157159

158-
return new JFRDataDescriptor(descriptor.getLabel(), descriptor.getDescription(), dataFormat, null, isNumeric);
160+
String dataName = descriptor.getLabel();
161+
if (isExperimental(descriptor)) dataName = "[Experimental] " + dataName;
162+
163+
return new JFRDataDescriptor(dataName, descriptor.getDescription(), dataFormat, null, isNumeric);
159164
}
160165

161166

@@ -184,6 +189,11 @@ static Comparable getDisplayValue(JFRJDK9Event event, ValueDescriptor descriptor
184189
}
185190

186191

192+
private static boolean isExperimental(ValueDescriptor descriptor) {
193+
return descriptor.getAnnotation(Experimental.class) != null;
194+
}
195+
196+
187197
private DisplayableSupport() {}
188198

189199

visualvm/jfr.jdk9/src/org/graalvm/visualvm/jfr/jdk9/model/impl/JFRJDK9EventType.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
2828
import java.util.Iterator;
2929
import java.util.List;
3030
import jdk.jfr.EventType;
31+
import jdk.jfr.Experimental;
3132
import jdk.jfr.ValueDescriptor;
3233
import org.graalvm.visualvm.jfr.model.JFRDataDescriptor;
3334
import org.graalvm.visualvm.jfr.model.JFREventType;
@@ -44,7 +45,7 @@ final class JFRJDK9EventType extends JFREventType {
4445
JFRJDK9EventType(EventType type) {
4546
this.type = type;
4647
}
47-
48+
4849

4950
@Override
5051
public long getId() {
@@ -58,7 +59,7 @@ public String getName() {
5859

5960
@Override
6061
public String getDisplayName() {
61-
return type.getLabel();
62+
return isExperimental() ? "[Experimental] " + type.getLabel() : type.getLabel();
6263
}
6364

6465
@Override
@@ -72,6 +73,12 @@ public List<String> getCategory() {
7273
}
7374

7475

76+
@Override
77+
public boolean isExperimental() {
78+
return type.getAnnotation(Experimental.class) != null;
79+
}
80+
81+
7582
@Override
7683
public List<JFRDataDescriptor> getDisplayableDataDescriptors(boolean includeExperimental) {
7784
List<JFRDataDescriptor> ddescriptors = new ArrayList();

visualvm/jfr/src/org/graalvm/visualvm/jfr/model/JFREventType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,9 @@ public abstract class JFREventType {
4343
public abstract List<String> getCategory();
4444

4545

46+
public abstract boolean isExperimental();
47+
48+
4649
public abstract List<JFRDataDescriptor> getDisplayableDataDescriptors(boolean includeExperimental);
4750

4851
}

visualvm/jfr/src/org/graalvm/visualvm/jfr/model/JFRModel.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
import java.time.Instant;
2929
import java.util.ArrayList;
3030
import java.util.HashMap;
31+
import java.util.HashSet;
3132
import java.util.Iterator;
3233
import java.util.List;
3334
import java.util.Map;
3435
import java.util.Properties;
36+
import java.util.Set;
3537
import java.util.logging.Level;
3638
import java.util.logging.Logger;
3739
import org.graalvm.visualvm.core.model.Model;
@@ -71,6 +73,7 @@ protected String getID() {
7173
private Instant firstEventTime;
7274
private Instant lastEventTime;
7375
private long eventsCount = 0;
76+
private long experimentalCount = 0;
7477

7578
private long firstEventTimeMs;
7679

@@ -129,6 +132,10 @@ public long getEventsCount() {
129132
return eventsCount;
130133
}
131134

135+
public long getExperimentalEventsCount() {
136+
return experimentalCount;
137+
}
138+
132139

133140
public Properties getSystemProperties() {
134141
return sysProps;
@@ -192,6 +199,15 @@ public long nsToAbsoluteMillis(long nanos) {
192199

193200
protected final void initialize() {
194201
sysProps = new Properties();
202+
203+
final Set<String> experimentalTypes = new HashSet();
204+
visitEventTypes(new JFREventTypeVisitor() {
205+
@Override
206+
public boolean visitType(String typeName, JFREventType eventType) {
207+
if (eventType.isExperimental()) experimentalTypes.add(typeName);
208+
return false;
209+
}
210+
});
195211

196212
visitEvents(new JFREventVisitor() {
197213
private List<? extends JFREventChecker> checkers;
@@ -203,6 +219,7 @@ public void init() {
203219
@Override
204220
public boolean visit(String typeName, JFREvent event) {
205221
eventsCount++;
222+
if (experimentalTypes.contains(typeName)) experimentalCount++;
206223

207224
if (!checkers.isEmpty()) {
208225
Iterator<? extends JFREventChecker> checkersI = checkers.iterator();

visualvm/jfr/src/org/graalvm/visualvm/jfr/views/recording/RecordingViewSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -140,6 +140,7 @@ private static String createSummary(JFRModel model) {
140140
String lastEventTime = InstantFormatter.format(lastTime);
141141
String totalTime = getTime(firstTime, lastTime);
142142
String eventsCount = NumberFormat.getIntegerInstance().format(model.getEventsCount());
143+
if (model.getExperimentalEventsCount() > 0) eventsCount += " (incl. " + NumberFormat.getIntegerInstance().format(model.getExperimentalEventsCount()) + " experimental)";
143144

144145
s.append("<tr>");
145146
s.append("<td><b>First event time:</b>&nbsp;</td><td>").append(firstEventTime).append("</td>");

0 commit comments

Comments
 (0)