53 fm = new JavacFileManager(new Context(), false, null); 54 JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + self + ".java"); 55 56 test(fm, f, 57 new Option[] { new Option("-d", ".")}, 58 8); 59 60 test(fm, f, 61 new Option[] { new XOption("-XprintRounds"), 62 new Option("-processorpath", "."), 63 new Option("-processor", self) }, 64 13); 65 } 66 67 static void test(JavacFileManager fm, JavaFileObject f, Option[] opts, int expect) throws Throwable { 68 PrintWriter out = new PrintWriter(System.err, true); 69 70 JavacTool tool = JavacTool.create(); 71 List<String> flags = new ArrayList<String>(); 72 flags.addAll(Arrays.asList( 73 "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", 74 "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", 75 "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")); 76 for (Option opt: opts) { 77 flags.add(opt.name); 78 for (Object arg : opt.args) 79 flags.add(arg.toString()); 80 } 81 82 JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out, 83 fm, 84 null, 85 flags, 86 null, 87 Arrays.asList(f)); 88 MyTaskListener tl = new MyTaskListener(); 89 task.setTaskListener(tl); 90 task.call(); 91 if (tl.started != expect) 92 throw new AssertionError("Unexpected number of TaskListener events; " 93 + "expected " + expect + ", found " + tl.started); 94 } 95 | 53 fm = new JavacFileManager(new Context(), false, null); 54 JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + self + ".java"); 55 56 test(fm, f, 57 new Option[] { new Option("-d", ".")}, 58 8); 59 60 test(fm, f, 61 new Option[] { new XOption("-XprintRounds"), 62 new Option("-processorpath", "."), 63 new Option("-processor", self) }, 64 13); 65 } 66 67 static void test(JavacFileManager fm, JavaFileObject f, Option[] opts, int expect) throws Throwable { 68 PrintWriter out = new PrintWriter(System.err, true); 69 70 JavacTool tool = JavacTool.create(); 71 List<String> flags = new ArrayList<String>(); 72 flags.addAll(Arrays.asList( 73 "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", 74 "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", 75 "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")); 76 for (Option opt: opts) { 77 flags.add(opt.name); 78 for (Object arg : opt.args) 79 flags.add(arg.toString()); 80 } 81 82 JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out, 83 fm, 84 null, 85 flags, 86 null, 87 Arrays.asList(f)); 88 MyTaskListener tl = new MyTaskListener(); 89 task.setTaskListener(tl); 90 task.call(); 91 if (tl.started != expect) 92 throw new AssertionError("Unexpected number of TaskListener events; " 93 + "expected " + expect + ", found " + tl.started); 94 } 95 |