langtools/test/tools/javac/processing/6430209/T6430209.java
changeset 27319 030080f03e4f
parent 24897 655b72d7b96e
child 30730 d3ce7619db2c
equal deleted inserted replaced
27318:4660a5da7d90 27319:030080f03e4f
    56         // -proc:only -processor b6341534 -cp . ./src/*.java
    56         // -proc:only -processor b6341534 -cp . ./src/*.java
    57         String testSrc = System.getProperty("test.src", ".");
    57         String testSrc = System.getProperty("test.src", ".");
    58         String testClassPath = System.getProperty("test.class.path");
    58         String testClassPath = System.getProperty("test.class.path");
    59         JavacTool tool = JavacTool.create();
    59         JavacTool tool = JavacTool.create();
    60         MyDiagListener dl = new MyDiagListener();
    60         MyDiagListener dl = new MyDiagListener();
    61         StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
    61         try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
    62         fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
    62             fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
    63         Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
    63             Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
    64             new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
    64                 new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
    65         Iterable<String> opts = Arrays.asList("-proc:only",
    65             Iterable<String> opts = Arrays.asList("-proc:only",
    66                                               "-processor", "b6341534",
    66                                                   "-processor", "b6341534",
    67                                               "-processorpath", testClassPath);
    67                                                   "-processorpath", testClassPath);
    68         StringWriter out = new StringWriter();
    68             StringWriter out = new StringWriter();
    69         JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
    69             JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
    70         task.call();
    70             task.call();
    71         String s = out.toString();
    71             String s = out.toString();
    72         System.err.print(s);
    72             System.err.print(s);
    73         // Expect the following 2 diagnostics, and no output to log
    73             // Expect the following 2 diagnostics, and no output to log
    74         System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
    74             System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
    75         if (dl.count != 2 || s.length() != 0)
    75             if (dl.count != 2 || s.length() != 0)
    76             throw new AssertionError("unexpected output from compiler");
    76                 throw new AssertionError("unexpected output from compiler");
       
    77         }
    77     }
    78     }
    78 
    79 
    79     static class MyDiagListener implements DiagnosticListener<JavaFileObject> {
    80     static class MyDiagListener implements DiagnosticListener<JavaFileObject> {
    80         public void report(Diagnostic d) {
    81         public void report(Diagnostic d) {
    81             System.err.println(d);
    82             System.err.println(d);