langtools/test/tools/javac/api/T6430241.java
changeset 27319 030080f03e4f
parent 8034 d3b29ef9c062
child 27579 d1a63c99cdd5
equal deleted inserted replaced
27318:4660a5da7d90 27319:030080f03e4f
     1     /*
     1     /*
     2      * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     2      * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
     3      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4      *
     4      *
     5      * This code is free software; you can redistribute it and/or modify it
     5      * This code is free software; you can redistribute it and/or modify it
     6      * under the terms of the GNU General Public License version 2 only, as
     6      * under the terms of the GNU General Public License version 2 only, as
     7      * published by the Free Software Foundation.
     7      * published by the Free Software Foundation.
   132 
   132 
   133         void testTaskAPI(boolean expectWarnings, Iterable<? extends File> pcp) throws Exception {
   133         void testTaskAPI(boolean expectWarnings, Iterable<? extends File> pcp) throws Exception {
   134             System.err.println("test task API: " + pcp);
   134             System.err.println("test task API: " + pcp);
   135 
   135 
   136             JavacTool tool = JavacTool.create();
   136             JavacTool tool = JavacTool.create();
   137             StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
   137             try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
   138 
   138 
   139             if (pcp != null)
   139                 if (pcp != null)
   140                 fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
   140                     fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
   141 
   141 
   142             Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);
   142                 Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);
   143 
   143 
   144             StringWriter sw = new StringWriter();
   144                 StringWriter sw = new StringWriter();
   145             PrintWriter pw = new PrintWriter(sw);
   145                 PrintWriter pw = new PrintWriter(sw);
   146             JavacTask task = tool.getTask(pw, fm, null, null, null, files);
   146                 JavacTask task = tool.getTask(pw, fm, null, null, null, files);
   147             boolean ok = task.call();
   147                 boolean ok = task.call();
   148             String out = showOutput(sw.toString());
   148                 String out = showOutput(sw.toString());
   149 
   149 
   150             checkCompilationOK(ok);
   150                 checkCompilationOK(ok);
   151             checkOutput(out, expectWarnings);
   151                 checkOutput(out, expectWarnings);
       
   152             }
   152         }
   153         }
   153 
   154 
   154         //----- utility methods
   155         //----- utility methods
   155 
   156 
   156         /**
   157         /**