langtools/test/tools/javac/api/taskListeners/CompileEvent.java
changeset 27319 030080f03e4f
parent 26264 a09fedde76be
child 30730 d3ce7619db2c
equal deleted inserted replaced
27318:4660a5da7d90 27319:030080f03e4f
    71         if (mainResult != 0)
    71         if (mainResult != 0)
    72             throw new AssertionError("Compilation failed unexpectedly, exit code: " + mainResult);
    72             throw new AssertionError("Compilation failed unexpectedly, exit code: " + mainResult);
    73         assertOutput(out.toString());
    73         assertOutput(out.toString());
    74 
    74 
    75         JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
    75         JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
    76         StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
    76         try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
    77         Iterable<? extends JavaFileObject> testFileObjects = fm.getJavaFileObjects(test);
    77             Iterable<? extends JavaFileObject> testFileObjects = fm.getJavaFileObjects(test);
    78 
    78 
    79         //test events fired to listeners registered from plugins
    79             //test events fired to listeners registered from plugins
    80         //when starting compiler using JavaCompiler.getTask(...).call
    80             //when starting compiler using JavaCompiler.getTask(...).call
    81         List<String> options =
    81             List<String> options =
    82                 Arrays.asList("-Xplugin:compile-event", "-processorpath", testClasses);
    82                     Arrays.asList("-Xplugin:compile-event", "-processorpath", testClasses);
    83         out = new StringWriter();
    83             out = new StringWriter();
    84         boolean compResult = comp.getTask(out, null, null, options, null, testFileObjects).call();
    84             boolean compResult = comp.getTask(out, null, null, options, null, testFileObjects).call();
    85         if (!compResult)
    85             if (!compResult)
    86             throw new AssertionError("Compilation failed unexpectedly.");
    86                 throw new AssertionError("Compilation failed unexpectedly.");
    87         assertOutput(out.toString());
    87             assertOutput(out.toString());
       
    88         }
    88     }
    89     }
    89 
    90 
    90     void assertOutput(String found) {
    91     void assertOutput(String found) {
    91         String lineSeparator = System.getProperty("line.separator");
    92         String lineSeparator = System.getProperty("line.separator");
    92         if (!found.trim().replace(lineSeparator, "\n").equals(EXPECTED)) {
    93         if (!found.trim().replace(lineSeparator, "\n").equals(EXPECTED)) {