langtools/test/tools/javac/profiles/ProfileOptionTest.java
changeset 27319 030080f03e4f
parent 26264 a09fedde76be
child 27579 d1a63c99cdd5
--- a/langtools/test/tools/javac/profiles/ProfileOptionTest.java	Wed Oct 29 12:09:17 2014 +0100
+++ b/langtools/test/tools/javac/profiles/ProfileOptionTest.java	Wed Oct 29 17:25:23 2014 -0700
@@ -236,24 +236,28 @@
 
     /** Run all test cases. */
     void run() throws Exception {
-        initTestClasses();
+        try {
+            initTestClasses();
 
-        for (Method m: getClass().getDeclaredMethods()) {
-            Annotation a = m.getAnnotation(Test.class);
-            if (a != null) {
-                System.err.println(m.getName());
-                try {
-                    m.invoke(this, new Object[] { });
-                } catch (InvocationTargetException e) {
-                    Throwable cause = e.getCause();
-                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
+            for (Method m: getClass().getDeclaredMethods()) {
+                Annotation a = m.getAnnotation(Test.class);
+                if (a != null) {
+                    System.err.println(m.getName());
+                    try {
+                        m.invoke(this, new Object[] { });
+                    } catch (InvocationTargetException e) {
+                        Throwable cause = e.getCause();
+                        throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                    }
+                    System.err.println();
                 }
-                System.err.println();
             }
+
+            if (errors > 0)
+                throw new Exception(errors + " errors occurred");
+        } finally {
+            fm.close();
         }
-
-        if (errors > 0)
-            throw new Exception(errors + " errors occurred");
     }
 
     void error(String msg) {