--- a/test/langtools/tools/javac/processing/6430209/T6430209.java Fri Mar 09 11:36:12 2018 +0800
+++ b/test/langtools/tools/javac/processing/6430209/T6430209.java Fri Mar 09 09:42:10 2018 +0100
@@ -37,9 +37,6 @@
import java.io.*;
import java.util.*;
-import javax.annotation.processing.*;
-import javax.lang.model.*;
-import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.source.util.*;
import com.sun.tools.javac.api.*;
@@ -59,32 +56,25 @@
String testSrc = System.getProperty("test.src", ".");
String testClassPath = System.getProperty("test.class.path");
JavacTool tool = JavacTool.create();
- MyDiagListener dl = new MyDiagListener();
- try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
- Iterable<String> opts = Arrays.asList("-proc:only",
+ Iterable<String> opts = Arrays.asList("-XDrawDiagnostics",
+ "-proc:only",
"-processor", "b6341534",
"-processorpath", testClassPath);
StringWriter out = new StringWriter();
- JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
+ JavacTask task = tool.getTask(out, fm, null, opts, null, files);
task.call();
String s = out.toString();
System.err.print(s);
- // Expect the following 2 diagnostics, and no output to log
- System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
- if (dl.count != 2 || s.length() != 0)
- throw new AssertionError("unexpected output from compiler");
+ s = s.replace(System.getProperty("line.separator"), "\n");
+ String expected = "test0.java:1:8: compiler.err.duplicate.class: test0\n" +
+ "1 error\n";
+ if (!expected.equals(s))
+ throw new AssertionError("unexpected text in output");
}
}
- static class MyDiagListener implements DiagnosticListener<JavaFileObject> {
- public void report(Diagnostic d) {
- System.err.println(d);
- count++;
- }
-
- public int count;
- }
}