--- a/langtools/test/tools/javac/tree/TreePosTest.java Wed Oct 29 12:09:17 2014 +0100
+++ b/langtools/test/tools/javac/tree/TreePosTest.java Wed Oct 29 17:25:23 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,7 @@
* args is the value of ${test.src}. In jtreg mode, the -r option can be
* given to change the default base directory to the root test directory.
*/
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src");
File baseDir = (testSrc == null) ? null : new File(testSrc);
boolean ok = new TreePosTest().run(baseDir, args);
@@ -133,61 +133,65 @@
* @param args command line args
* @return true if successful or in gui mode
*/
- boolean run(File baseDir, String... args) {
- if (args.length == 0) {
- usage(System.out);
- return true;
- }
+ boolean run(File baseDir, String... args) throws IOException {
+ try {
+ if (args.length == 0) {
+ usage(System.out);
+ return true;
+ }
- List<File> files = new ArrayList<File>();
- for (int i = 0; i < args.length; i++) {
- String arg = args[i];
- if (arg.equals("-encoding") && i + 1 < args.length)
- encoding = args[++i];
- else if (arg.equals("-gui"))
- gui = true;
- else if (arg.equals("-q"))
- quiet = true;
- else if (arg.equals("-v"))
- verbose = true;
- else if (arg.equals("-t") && i + 1 < args.length)
- tags.add(args[++i]);
- else if (arg.equals("-ef") && i + 1 < args.length)
- excludeFiles.add(new File(baseDir, args[++i]));
- else if (arg.equals("-et") && i + 1 < args.length)
- excludeTags.add(args[++i]);
- else if (arg.equals("-r")) {
- if (excludeFiles.size() > 0)
- throw new Error("-r must be used before -ef");
- File d = baseDir;
- while (!new File(d, "TEST.ROOT").exists()) {
- d = d.getParentFile();
- if (d == null)
- throw new Error("cannot find TEST.ROOT");
+ List<File> files = new ArrayList<File>();
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
+ if (arg.equals("-encoding") && i + 1 < args.length)
+ encoding = args[++i];
+ else if (arg.equals("-gui"))
+ gui = true;
+ else if (arg.equals("-q"))
+ quiet = true;
+ else if (arg.equals("-v"))
+ verbose = true;
+ else if (arg.equals("-t") && i + 1 < args.length)
+ tags.add(args[++i]);
+ else if (arg.equals("-ef") && i + 1 < args.length)
+ excludeFiles.add(new File(baseDir, args[++i]));
+ else if (arg.equals("-et") && i + 1 < args.length)
+ excludeTags.add(args[++i]);
+ else if (arg.equals("-r")) {
+ if (excludeFiles.size() > 0)
+ throw new Error("-r must be used before -ef");
+ File d = baseDir;
+ while (!new File(d, "TEST.ROOT").exists()) {
+ d = d.getParentFile();
+ if (d == null)
+ throw new Error("cannot find TEST.ROOT");
+ }
+ baseDir = d;
}
- baseDir = d;
+ else if (arg.startsWith("-"))
+ throw new Error("unknown option: " + arg);
+ else {
+ while (i < args.length)
+ files.add(new File(baseDir, args[i++]));
+ }
}
- else if (arg.startsWith("-"))
- throw new Error("unknown option: " + arg);
- else {
- while (i < args.length)
- files.add(new File(baseDir, args[i++]));
- }
- }
- for (File file: files) {
- if (file.exists())
- test(file);
- else
- error("File not found: " + file);
- }
+ for (File file: files) {
+ if (file.exists())
+ test(file);
+ else
+ error("File not found: " + file);
+ }
- if (fileCount != 1)
- System.err.println(fileCount + " files read");
- if (errors > 0)
- System.err.println(errors + " errors");
+ if (fileCount != 1)
+ System.err.println(fileCount + " files read");
+ if (errors > 0)
+ System.err.println(errors + " errors");
- return (gui || errors == 0);
+ return (gui || errors == 0);
+ } finally {
+ fm.close();
+ }
}
/**