# HG changeset patch # User jjh # Date 1293136161 28800 # Node ID f72ce57eb9c129f8622dfe260a6ba7eb5412a7ab # Parent 85446adf08d8121fe4385bcc24063cc138e4e053 6982992: Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout Summary: Hoist some invariant code out of a loop Reviewed-by: ksrini diff -r 85446adf08d8 -r f72ce57eb9c1 langtools/test/tools/javac/failover/CheckAttributedTree.java --- a/langtools/test/tools/javac/failover/CheckAttributedTree.java Thu Dec 23 10:08:53 2010 -0800 +++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java Thu Dec 23 12:29:21 2010 -0800 @@ -252,6 +252,13 @@ error("File " + file + " ignored"); } + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + Reporter r = new Reporter(pw); + JavacTool tool = JavacTool.create(); + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); + /** * Read a file. * @param file the file to be read @@ -260,12 +267,8 @@ * @throws TreePosTest.ParseException if any errors occur while parsing the file */ List> read(File file) throws IOException, AttributionException { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - Reporter r = new Reporter(pw); JavacTool tool = JavacTool.create(); - Charset cs = (encoding == null ? null : Charset.forName(encoding)); - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); + r.errors = 0; Iterable files = fm.getJavaFileObjects(file); String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" }; JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files); diff -r 85446adf08d8 -r f72ce57eb9c1 langtools/test/tools/javac/tree/AbstractTreeScannerTest.java --- a/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Dec 23 10:08:53 2010 -0800 +++ b/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Dec 23 12:29:21 2010 -0800 @@ -143,6 +143,13 @@ abstract int test(JCCompilationUnit t); + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + Reporter r = new Reporter(pw); + JavacTool tool = JavacTool.create(); + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); + /** * Read a file. * @param file the file to be read @@ -151,11 +158,8 @@ * @throws TreePosTest.ParseException if any errors occur while parsing the file */ JCCompilationUnit read(File file) throws IOException, ParseException { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - Reporter r = new Reporter(pw); JavacTool tool = JavacTool.create(); - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); + r.errors = 0; Iterable files = fm.getJavaFileObjects(file); JavacTask task = tool.getTask(pw, fm, r, Collections.emptyList(), null, files); Iterable trees = task.parse(); diff -r 85446adf08d8 -r f72ce57eb9c1 langtools/test/tools/javac/tree/TreePosTest.java --- a/langtools/test/tools/javac/tree/TreePosTest.java Thu Dec 23 10:08:53 2010 -0800 +++ b/langtools/test/tools/javac/tree/TreePosTest.java Thu Dec 23 12:29:21 2010 -0800 @@ -249,6 +249,13 @@ error("File " + file + " ignored"); } + // See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + Reporter r = new Reporter(pw); + JavacTool tool = JavacTool.create(); + StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); + /** * Read a file. * @param file the file to be read @@ -257,12 +264,8 @@ * @throws TreePosTest.ParseException if any errors occur while parsing the file */ JCCompilationUnit read(File file) throws IOException, ParseException { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - Reporter r = new Reporter(pw); JavacTool tool = JavacTool.create(); - Charset cs = (encoding == null ? null : Charset.forName(encoding)); - StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null); + r.errors = 0; Iterable files = fm.getJavaFileObjects(file); JavacTask task = tool.getTask(pw, fm, r, Collections.emptyList(), null, files); Iterable trees = task.parse();