|
20 | 20 | import java.lang.reflect.Method;
|
21 | 21 | import java.nio.charset.StandardCharsets;
|
22 | 22 | import java.nio.file.Files;
|
23 |
| -import java.util.Arrays; |
| 23 | +import java.util.List; |
24 | 24 | import java.util.Locale;
|
25 | 25 |
|
26 | 26 | import javax.tools.DiagnosticCollector;
|
@@ -84,6 +84,7 @@ protected void setUp() {
|
84 | 84 | compileTestProgram();
|
85 | 85 | } catch (Exception e) {
|
86 | 86 | StringWriter err = new StringWriter();
|
| 87 | + err.append(e.getMessage()); |
87 | 88 | e.printStackTrace(new PrintWriter(err));
|
88 | 89 | fail("Error in setup: " + err.toString());
|
89 | 90 | }
|
@@ -118,9 +119,9 @@ private static void compileFiles(String sourceFilePath, String outputPath) throw
|
118 | 119 | if (!outputFolder.exists()) {
|
119 | 120 | Files.createDirectories(outputFolder.toPath());
|
120 | 121 | }
|
121 |
| - String[] options = new String[] { "--release", "21", "-d", outputFolder.getAbsolutePath(), "-g", "-proc:none" }; |
| 122 | + List<String> options = List.of("--release", "21", "-d", outputFolder.getAbsolutePath(), "-g", "-proc:none"); |
122 | 123 | final StringWriter output = new StringWriter();
|
123 |
| - CompilationTask task = compiler.getTask(output, fileManager, diagnosticCollector, Arrays.asList(options), null, javaFileObjects); |
| 124 | + CompilationTask task = compiler.getTask(output, fileManager, diagnosticCollector, options, null, javaFileObjects); |
124 | 125 | boolean result = task.call();
|
125 | 126 | if (!result) {
|
126 | 127 | throw new IllegalArgumentException("Compilation failed:\n'" + output + "', compiler name: '" + compiler.name()
|
@@ -164,36 +165,26 @@ public void testJDIThreadEvents() {
|
164 | 165 |
|
165 | 166 | /**
|
166 | 167 | * Test restricting JDI ThreadStartEvent/ThreadDeathEvent to platform threads only
|
| 168 | + * |
| 169 | + * @throws Exception |
167 | 170 | */
|
168 |
| - public void testJDIPlatformThreadsOnlyFilter() { |
| 171 | + public void testJDIPlatformThreadsOnlyFilter() throws Exception { |
169 | 172 | // Make sure the entire VM is not suspended before we start a new thread
|
170 | 173 | // (otherwise this new thread will start suspended and we will never get the
|
171 | 174 | // ThreadStart event)
|
172 | 175 | fVM.resume();
|
173 | 176 |
|
174 | 177 | // Trigger a thread start event
|
175 | 178 | ThreadStartRequest vThreadStartRequest = fVM.eventRequestManager().createThreadStartRequest();
|
176 |
| - try { |
177 |
| - Method method = vThreadStartRequest.getClass().getMethod("addPlatformThreadsOnlyFilter"); |
178 |
| - method.invoke(vThreadStartRequest); |
179 |
| - } catch (NoSuchMethodException | SecurityException e) { |
180 |
| - fail("1"); |
181 |
| - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { |
182 |
| - fail("2"); |
183 |
| - } |
| 179 | + Method method = vThreadStartRequest.getClass().getMethod("addPlatformThreadsOnlyFilter"); |
| 180 | + method.invoke(vThreadStartRequest); |
184 | 181 | ThreadStartEvent startEvent = (ThreadStartEvent) triggerAndWait(vThreadStartRequest, "ThreadStartEvent", true, 3000);
|
185 | 182 | assertNull("3", startEvent);
|
186 | 183 |
|
187 | 184 | // Trigger a thread death event
|
188 | 185 | ThreadDeathRequest vThreadDeathRequest = fVM.eventRequestManager().createThreadDeathRequest();
|
189 |
| - try { |
190 |
| - Method method = vThreadDeathRequest.getClass().getMethod("addPlatformThreadsOnlyFilter"); |
191 |
| - method.invoke(vThreadDeathRequest); |
192 |
| - } catch (NoSuchMethodException | SecurityException e) { |
193 |
| - fail("4"); |
194 |
| - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { |
195 |
| - fail("5"); |
196 |
| - } |
| 186 | + method = vThreadDeathRequest.getClass().getMethod("addPlatformThreadsOnlyFilter"); |
| 187 | + method.invoke(vThreadDeathRequest); |
197 | 188 | ThreadDeathEvent deathEvent = (ThreadDeathEvent) triggerAndWait(vThreadDeathRequest, "ThreadDeathEvent", true, 3000);
|
198 | 189 | assertNull("6", deathEvent);
|
199 | 190 | }
|
|
0 commit comments