|
30 | 30 | import java.util.Map; |
31 | 31 | import java.util.Set; |
32 | 32 |
|
33 | | -import org.graalvm.compiler.serviceprovider.JavaVersionUtil; |
34 | 33 | import org.graalvm.nativeimage.Platform; |
35 | 34 | import org.graalvm.nativeimage.Platforms; |
36 | 35 |
|
|
44 | 43 | * Parses the flight recorder logging configuration and enables the logging according to that |
45 | 44 | * configuration. |
46 | 45 | */ |
47 | | -class JfrLogConfiguration { |
| 46 | +final class JfrLogConfiguration { |
48 | 47 | private static final String EMPTY_STRING_DEFAULT_CONFIG = "all=info"; |
49 | 48 | static final Map<LogTag, Set<JfrLogTag>> LOG_TAG_SETS = createLogTagSets(); |
50 | 49 |
|
51 | 50 | @Platforms(Platform.HOSTED_ONLY.class) |
52 | | - JfrLogConfiguration() { |
| 51 | + private JfrLogConfiguration() { |
53 | 52 | } |
54 | 53 |
|
55 | | - void parse(String str) { |
| 54 | + static void parse(String str) { |
56 | 55 | if (str.equalsIgnoreCase("disable")) { |
57 | 56 | return; |
58 | 57 | } |
@@ -98,34 +97,18 @@ private static void verifySelections(JfrLogSelection[] selections) { |
98 | 97 | } |
99 | 98 | } |
100 | 99 |
|
| 100 | + @Platforms(Platform.HOSTED_ONLY.class) |
101 | 101 | private static Map<LogTag, Set<JfrLogTag>> createLogTagSets() { |
102 | 102 | Map<LogTag, Set<JfrLogTag>> result = new EnumMap<>(LogTag.class); |
103 | | - result.put(LogTag.JFR, EnumSet.of(JfrLogTag.JFR)); |
104 | | - result.put(LogTag.JFR_SYSTEM, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM)); |
105 | | - result.put(LogTag.JFR_SYSTEM_EVENT, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM, JfrLogTag.EVENT)); |
106 | | - result.put(LogTag.JFR_SYSTEM_SETTING, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM, JfrLogTag.SETTING)); |
107 | | - result.put(LogTag.JFR_SYSTEM_BYTECODE, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM, JfrLogTag.BYTECODE)); |
108 | | - result.put(LogTag.JFR_SYSTEM_PARSER, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM, JfrLogTag.PARSER)); |
109 | | - result.put(LogTag.JFR_SYSTEM_METADATA, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM, JfrLogTag.METADATA)); |
110 | | - result.put(LogTag.JFR_METADATA, EnumSet.of(JfrLogTag.JFR, JfrLogTag.METADATA)); |
111 | | - result.put(LogTag.JFR_EVENT, EnumSet.of(JfrLogTag.JFR, JfrLogTag.EVENT)); |
112 | | - result.put(LogTag.JFR_SETTING, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SETTING)); |
113 | | - result.put(LogTag.JFR_DCMD, EnumSet.of(JfrLogTag.JFR, JfrLogTag.DCMD)); |
114 | | - |
115 | | - // JDK17 support |
116 | | - if (JavaVersionUtil.JAVA_SPEC >= 17) { |
117 | | - try { |
118 | | - LogTag jfrSystemStreaming = Enum.valueOf(LogTag.class, "JFR_SYSTEM_STREAMING"); |
119 | | - LogTag jfrSystemThrottle = Enum.valueOf(LogTag.class, "JFR_SYSTEM_THROTTLE"); |
120 | | - result.put(jfrSystemStreaming, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM, JfrLogTag.STREAMING)); |
121 | | - result.put(jfrSystemThrottle, EnumSet.of(JfrLogTag.JFR, JfrLogTag.SYSTEM, JfrLogTag.THROTTLE)); |
122 | | - LogTag jfrStart = Enum.valueOf(LogTag.class, "JFR_START"); |
123 | | - result.put(jfrStart, EnumSet.of(JfrLogTag.JFR, JfrLogTag.START)); |
124 | | - } catch (IllegalArgumentException | NullPointerException e) { |
125 | | - throw VMError.shouldNotReachHere("Should be defined", e); |
| 103 | + for (LogTag logTag : LogTag.values()) { |
| 104 | + EnumSet<JfrLogTag> logTagSet = EnumSet.noneOf(JfrLogTag.class); |
| 105 | + for (String t : logTag.name().split("_")) { |
| 106 | + /* This fails if a new JDK version adds entries to jdk.jfr.internal. */ |
| 107 | + logTagSet.add(JfrLogTag.valueOf(t)); |
126 | 108 | } |
| 109 | + VMError.guarantee(!logTagSet.isEmpty()); |
| 110 | + result.put(logTag, logTagSet); |
127 | 111 | } |
128 | | - |
129 | 112 | return result; |
130 | 113 | } |
131 | 114 |
|
|
0 commit comments