Thu, 23 Dec 2010 12:29:21 -0800
6982992: Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
Summary: Hoist some invariant code out of a loop
Reviewed-by: ksrini
1.1 --- a/test/tools/javac/failover/CheckAttributedTree.java Thu Dec 23 10:08:53 2010 -0800 1.2 +++ b/test/tools/javac/failover/CheckAttributedTree.java Thu Dec 23 12:29:21 2010 -0800 1.3 @@ -252,6 +252,13 @@ 1.4 error("File " + file + " ignored"); 1.5 } 1.6 1.7 + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout 1.8 + StringWriter sw = new StringWriter(); 1.9 + PrintWriter pw = new PrintWriter(sw); 1.10 + Reporter r = new Reporter(pw); 1.11 + JavacTool tool = JavacTool.create(); 1.12 + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 1.13 + 1.14 /** 1.15 * Read a file. 1.16 * @param file the file to be read 1.17 @@ -260,12 +267,8 @@ 1.18 * @throws TreePosTest.ParseException if any errors occur while parsing the file 1.19 */ 1.20 List<Pair<JCCompilationUnit, JCTree>> read(File file) throws IOException, AttributionException { 1.21 - StringWriter sw = new StringWriter(); 1.22 - PrintWriter pw = new PrintWriter(sw); 1.23 - Reporter r = new Reporter(pw); 1.24 JavacTool tool = JavacTool.create(); 1.25 - Charset cs = (encoding == null ? null : Charset.forName(encoding)); 1.26 - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 1.27 + r.errors = 0; 1.28 Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file); 1.29 String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" }; 1.30 JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files);
2.1 --- a/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Dec 23 10:08:53 2010 -0800 2.2 +++ b/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Dec 23 12:29:21 2010 -0800 2.3 @@ -143,6 +143,13 @@ 2.4 2.5 abstract int test(JCCompilationUnit t); 2.6 2.7 + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout 2.8 + StringWriter sw = new StringWriter(); 2.9 + PrintWriter pw = new PrintWriter(sw); 2.10 + Reporter r = new Reporter(pw); 2.11 + JavacTool tool = JavacTool.create(); 2.12 + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 2.13 + 2.14 /** 2.15 * Read a file. 2.16 * @param file the file to be read 2.17 @@ -151,11 +158,8 @@ 2.18 * @throws TreePosTest.ParseException if any errors occur while parsing the file 2.19 */ 2.20 JCCompilationUnit read(File file) throws IOException, ParseException { 2.21 - StringWriter sw = new StringWriter(); 2.22 - PrintWriter pw = new PrintWriter(sw); 2.23 - Reporter r = new Reporter(pw); 2.24 JavacTool tool = JavacTool.create(); 2.25 - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 2.26 + r.errors = 0; 2.27 Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file); 2.28 JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files); 2.29 Iterable<? extends CompilationUnitTree> trees = task.parse();
3.1 --- a/test/tools/javac/tree/TreePosTest.java Thu Dec 23 10:08:53 2010 -0800 3.2 +++ b/test/tools/javac/tree/TreePosTest.java Thu Dec 23 12:29:21 2010 -0800 3.3 @@ -249,6 +249,13 @@ 3.4 error("File " + file + " ignored"); 3.5 } 3.6 3.7 + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout 3.8 + StringWriter sw = new StringWriter(); 3.9 + PrintWriter pw = new PrintWriter(sw); 3.10 + Reporter r = new Reporter(pw); 3.11 + JavacTool tool = JavacTool.create(); 3.12 + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 3.13 + 3.14 /** 3.15 * Read a file. 3.16 * @param file the file to be read 3.17 @@ -257,12 +264,8 @@ 3.18 * @throws TreePosTest.ParseException if any errors occur while parsing the file 3.19 */ 3.20 JCCompilationUnit read(File file) throws IOException, ParseException { 3.21 - StringWriter sw = new StringWriter(); 3.22 - PrintWriter pw = new PrintWriter(sw); 3.23 - Reporter r = new Reporter(pw); 3.24 JavacTool tool = JavacTool.create(); 3.25 - Charset cs = (encoding == null ? null : Charset.forName(encoding)); 3.26 - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); 3.27 + r.errors = 0; 3.28 Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file); 3.29 JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files); 3.30 Iterable<? extends CompilationUnitTree> trees = task.parse();