8062514: Update ToolTester tests to close file manager
authorjjg
Wed, 29 Oct 2014 19:07:34 -0700
changeset 27321 c8eceba990bf
parent 27320 f0739350a62d
child 27322 14c8294d03a4
8062514: Update ToolTester tests to close file manager Reviewed-by: darcy
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
langtools/test/tools/javac/api/6406133/T6406133.java
langtools/test/tools/javac/api/6410643/T6410643.java
langtools/test/tools/javac/api/6411310/T6411310.java
langtools/test/tools/javac/api/6411333/T6411333.java
langtools/test/tools/javac/api/6412656/T6412656.java
langtools/test/tools/javac/api/6415780/T6415780.java
langtools/test/tools/javac/api/6418694/T6418694.java
langtools/test/tools/javac/api/6421111/T6421111.java
langtools/test/tools/javac/api/6421756/T6421756.java
langtools/test/tools/javac/api/6422215/T6422215.java
langtools/test/tools/javac/api/6422327/T6422327.java
langtools/test/tools/javac/api/6423003/T6423003.java
langtools/test/tools/javac/api/6431257/T6431257.java
langtools/test/tools/javac/api/6437349/T6437349.java
langtools/test/tools/javac/api/6437999/T6437999.java
langtools/test/tools/javac/api/6440333/T6440333.java
langtools/test/tools/javac/api/6440528/T6440528.java
langtools/test/tools/javac/api/6468404/T6468404.java
langtools/test/tools/javac/api/6731573/T6731573.java
langtools/test/tools/javac/api/6733837/T6733837.java
langtools/test/tools/javac/api/TestJavacTaskScanner.java
langtools/test/tools/javac/api/TestResolveError.java
langtools/test/tools/javac/api/guide/Test.java
langtools/test/tools/javac/api/lib/ToolTester.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Oct 29 19:07:34 2014 -0700
@@ -130,6 +130,8 @@
         if (register)
             context.put(JavaFileManager.class, this);
         setContext(context);
+        if (System.getProperty("show.fm.open.close") != null)
+            System.err.println("JavacFileManager.open " + this.hashCode());
     }
 
     /**
@@ -571,6 +573,8 @@
      */
     @DefinedBy(Api.COMPILER)
     public void close() {
+        if (System.getProperty("show.fm.open.close") != null)
+            System.err.println("JavacFileManager.close " + this.hashCode());
         for (Iterator<Archive> i = archives.values().iterator(); i.hasNext(); ) {
             Archive a = i.next();
             i.remove();
--- a/langtools/test/tools/javac/api/6406133/T6406133.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6406133/T6406133.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -106,6 +106,8 @@
     }
 
     public static void main(String... args) throws Exception {
-        new T6406133().test();
+        try (T6406133 t = new T6406133()) {
+            t.test();
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6410643/T6410643.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6410643/T6410643.java	Wed Oct 29 19:07:34 2014 -0700
@@ -31,6 +31,7 @@
  * @run main T6410643
  */
 
+import java.io.IOException;
 import javax.tools.JavaFileObject;
 import static java.util.Collections.singleton;
 
@@ -68,7 +69,10 @@
         testGetTask(s,    s,    f);
         System.err.println("Test result: PASSED");
     }
-    public static void main(String... args) {
-        new T6410643().test(args);
+
+    public static void main(String... args) throws IOException {
+        try (T6410643 t = new T6410643()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6411310/T6411310.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6411310/T6411310.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -54,6 +54,8 @@
     }
 
     public static void main(String... args) throws IOException {
-        new T6411310().test(args);
+        try (T6411310 t = new T6411310()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6411333/T6411333.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6411333/T6411333.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -82,7 +82,10 @@
         testRelativeUri("util/List.java", false);
         testRelativeUri("/util/List.java", true);
     }
-    public static void main(String... args) {
-        new T6411333().test(args);
+
+    public static void main(String... args) throws IOException {
+        try (T6411333 t = new T6411333()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6412656/T6412656.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6412656/T6412656.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -31,6 +31,7 @@
  * @run main T6412656
  */
 
+import java.io.IOException;
 import java.util.Set;
 import java.util.Collections;
 import javax.lang.model.element.TypeElement;
@@ -52,8 +53,10 @@
         System.out.println("OK");
     }
 
-    public static void main(String... args) {
-        new T6412656().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6412656 t = new T6412656()) {
+            t.test(args);
+        }
     }
 
     @SupportedAnnotationTypes("*")
--- a/langtools/test/tools/javac/api/6415780/T6415780.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6415780/T6415780.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -32,6 +32,7 @@
  * @run main T6415780
  */
 
+import java.io.IOException;
 import static javax.tools.StandardLocation.CLASS_PATH;
 
 public class T6415780 extends ToolTester {
@@ -39,8 +40,9 @@
         System.out.println(fm.getClassLoader(CLASS_PATH).toString()); // null-check
     }
 
-    public static void main(String... args) {
-        T6415780 tester = new T6415780();
-        tester.test();
+    public static void main(String... args) throws IOException {
+        try (T6415780 tester = new T6415780()) {
+            tester.test();
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6418694/T6418694.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6418694/T6418694.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -32,6 +32,7 @@
  * @run main T6418694
  */
 
+import java.io.IOException;
 import javax.tools.StandardLocation;
 
 public class T6418694 extends ToolTester {
@@ -52,7 +53,9 @@
             }
         }
     }
-    public static void main(String... args) {
-        new T6418694().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6418694 t = new T6418694()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6421111/T6421111.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6421111/T6421111.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -33,6 +33,7 @@
  */
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Collections;
@@ -101,8 +102,10 @@
             return SourceVersion.latest();
         }
     }
-    public static void main(String... args) {
-        new T6421111().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6421111 t = new T6421111()) {
+            t.test(args);
+        }
     }
     public static AssertionError error(String format, Object... args) {
         return new AssertionError(String.format(format, args));
--- a/langtools/test/tools/javac/api/6421756/T6421756.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6421756/T6421756.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -32,6 +32,7 @@
  * @run main T6421756
  */
 
+import java.io.IOException;
 import java.util.Collections;
 
 public class T6421756 extends ToolTester {
@@ -44,7 +45,9 @@
             System.out.println("OK: got expected error " + e.getLocalizedMessage());
         }
     }
-    public static void main(String... args) {
-        new T6421756().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6421756 t = new T6421756()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6422215/T6422215.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6422215/T6422215.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -46,7 +46,9 @@
             System.out.println("OK: caught expected exception: " + e.getLocalizedMessage());
         }
     }
-    public static void main(String... args) {
-        new T6422215().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6422215 t = new T6422215()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6422327/T6422327.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6422327/T6422327.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -32,6 +32,7 @@
  */
 
 import java.io.File;
+import java.io.IOException;
 
 public class T6422327 extends ToolTester {
     void test(String... args) {
@@ -43,7 +44,9 @@
             System.err.println("OK, got expected exception: " + e.getLocalizedMessage());
         }
     }
-    public static void main(String... args) {
-        new T6422327().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6422327 t = new T6422327()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6423003/T6423003.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6423003/T6423003.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -32,6 +32,7 @@
  * @run main T6423003
  */
 
+import java.io.IOException;
 import java.util.Arrays;
 
 public class T6423003 extends ToolTester {
@@ -44,7 +45,9 @@
         }
         throw new AssertionError("Expected IllegalStateException not thrown");
     }
-    public static void main(String... args) {
-        new T6423003().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6423003 t = new T6423003()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6431257/T6431257.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6431257/T6431257.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -67,6 +67,8 @@
     }
 
     public static void main(String... args) throws IOException {
-        new T6431257().test(args);
+        try (T6431257 t = new T6431257()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6437349/T6437349.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6437349/T6437349.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -51,6 +51,8 @@
             throw new AssertionError();
     }
     public static void main(String... args) throws IOException {
-        new T6437349().test(args);
+        try (T6437349 t = new T6437349()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6437999/T6437999.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6437999/T6437999.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -86,6 +86,8 @@
             throw new AssertionError("Error in UTF-8 mode");
     }
     public static void main(String... args) throws IOException {
-        new T6437999().test(args);
+        try (T6437999 t = new T6437999()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6440333/T6440333.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6440333/T6440333.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -50,6 +50,8 @@
         }
     }
     public static void main(String... args) throws IOException {
-        new T6440333().test(args);
+        try (T6440333 t = new T6440333()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6440528/T6440528.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6440528/T6440528.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -66,6 +66,8 @@
     }
 
     public static void main(String... args) throws Exception {
-        new T6440528().test(args);
+        try (T6440528 t = new T6440528()) {
+            t.test(args);
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6468404/T6468404.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6468404/T6468404.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -88,8 +88,10 @@
         if (!task.call())
             throw new AssertionError();
     }
-    public static void main(String... args) {
-        new T6468404().test(args);
+    public static void main(String... args) throws IOException {
+        try (T6468404 t = new T6468404()) {
+            t.test(args);
+        }
     }
 
 }
--- a/langtools/test/tools/javac/api/6731573/T6731573.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6731573/T6731573.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -106,6 +106,8 @@
     }
 
     public static void main(String... args) throws Exception {
-        new T6731573().test();
+        try (T6731573 t = new T6731573()) {
+            t.test();
+        }
     }
 }
--- a/langtools/test/tools/javac/api/6733837/T6733837.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/6733837/T6733837.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -31,6 +31,7 @@
  * @run main T6733837
  */
 
+import java.io.IOException;
 import java.io.StringWriter;
 import java.io.PrintWriter;
 import java.net.URI;
@@ -43,8 +44,10 @@
 
 public class T6733837 extends ToolTester {
 
-    public static void main(String... args) {
-        new T6733837().exec();
+    public static void main(String... args) throws IOException {
+        try (T6733837 t = new T6733837()) {
+            t.exec();
+        }
     }
 
     public void exec() {
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Wed Oct 29 19:07:34 2014 -0700
@@ -115,7 +115,9 @@
 
     public static void main(String... args) throws IOException {
         String srcdir = System.getProperty("test.src");
-        new TestJavacTaskScanner(new File(srcdir, args[0])).run();
+        try (TestJavacTaskScanner t = new TestJavacTaskScanner(new File(srcdir, args[0]))) {
+            t.run();
+        }
     }
 
     private void testGetAllMembers(TypeElement clazz) {
--- a/langtools/test/tools/javac/api/TestResolveError.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/TestResolveError.java	Wed Oct 29 19:07:34 2014 -0700
@@ -51,7 +51,9 @@
  */
 public class TestResolveError extends ToolTester {
     public static void main(String... args) throws Exception {
-        new TestResolveError().run();
+        try (TestResolveError t = new TestResolveError()) {
+            t.run();
+        }
     }
 
     void run() throws Exception {
--- a/langtools/test/tools/javac/api/guide/Test.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/guide/Test.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -80,7 +80,9 @@
     }
 
     public static void main(String... args) throws Exception {
-        new Test().test(args);
+        try (Test t = new Test()) {
+            t.test(args);
+        }
     }
 
 }
--- a/langtools/test/tools/javac/api/lib/ToolTester.java	Wed Oct 29 18:01:22 2014 -0700
+++ b/langtools/test/tools/javac/api/lib/ToolTester.java	Wed Oct 29 19:07:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -31,7 +31,7 @@
 import static javax.tools.StandardLocation.SOURCE_PATH;
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
 
-public class ToolTester {
+public class ToolTester implements AutoCloseable {
     public final File test_src     = new File(System.getProperty("test.src", "."));
     public final File test_classes = new File(System.getProperty("test.classes", "."));
     public final List<File> test_class_path = pathToFiles(System.getProperty("test.class.path"),
@@ -77,4 +77,9 @@
         result.addAll(b);
         return result;
     }
+
+    @Override
+    public void close() throws IOException {
+        fm.close();
+    }
 }