136 Flag.setStringValue(name, value);
137 } else {
138 throw new IllegalArgumentException("VM Option \"" +
139 name + "\" is of an unsupported type: " +
140 v.getClass().getName());
141 }
142 }
143
144 @Override
145 public ObjectName getObjectName() {
146 return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
147 }
148
149 @Override
150 public void dumpThreads(String outputFile, ThreadDumpFormat format) throws IOException {
151 Path file = Path.of(outputFile);
152 if (!file.isAbsolute())
153 throw new IllegalArgumentException("'outputFile' not absolute path");
154
155 try (OutputStream out = Files.newOutputStream(file, StandardOpenOption.CREATE_NEW)) {
156 dumpThreads(out, format);
157 }
158 }
159
160 private void dumpThreads(OutputStream out, ThreadDumpFormat format) throws IOException {
161 switch (format) {
162 case TEXT_PLAIN -> ThreadDumper.dumpThreads(out);
163 case JSON -> ThreadDumper.dumpThreadsToJson(out);
164 }
165 }
166 }
|
136 Flag.setStringValue(name, value);
137 } else {
138 throw new IllegalArgumentException("VM Option \"" +
139 name + "\" is of an unsupported type: " +
140 v.getClass().getName());
141 }
142 }
143
144 @Override
145 public ObjectName getObjectName() {
146 return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
147 }
148
149 @Override
150 public void dumpThreads(String outputFile, ThreadDumpFormat format) throws IOException {
151 Path file = Path.of(outputFile);
152 if (!file.isAbsolute())
153 throw new IllegalArgumentException("'outputFile' not absolute path");
154
155 try (OutputStream out = Files.newOutputStream(file, StandardOpenOption.CREATE_NEW)) {
156 dumpThreads(out, format);
157 }
158 }
159
160 private void dumpThreads(OutputStream out, ThreadDumpFormat format) throws IOException {
161 switch (format) {
162 case TEXT_PLAIN -> ThreadDumper.dumpThreads(out);
163 case JSON -> ThreadDumper.dumpThreadsToJson(out);
164 }
165 }
166 }
|