langtools/test/tools/javac/generics/bridges/BridgeHarness.java
changeset 27319 030080f03e4f
parent 18731 38dd7ede2dfb
child 30730 d3ce7619db2c
--- a/langtools/test/tools/javac/generics/bridges/BridgeHarness.java	Wed Oct 29 12:09:17 2014 +0100
+++ b/langtools/test/tools/javac/generics/bridges/BridgeHarness.java	Wed Oct 29 17:25:23 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -70,19 +70,23 @@
     static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
 
     public static void main(String[] args) throws Exception {
-        //set sourcepath
-        fm.setLocation(SOURCE_PATH,
-                Arrays.asList(new File(System.getProperty("test.src"), "tests")));
-        //set output (-d)
-        fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT,
-                Arrays.asList(new File(System.getProperty("user.dir"))));
-        for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
-            //for each source, compile and check against annotations
-            new BridgeHarness(jfo).compileAndCheck();
-        }
-        //if there were errors, fail
-        if (nerrors > 0) {
-            throw new AssertionError("Errors were found");
+        try {
+            //set sourcepath
+            fm.setLocation(SOURCE_PATH,
+                    Arrays.asList(new File(System.getProperty("test.src"), "tests")));
+            //set output (-d)
+            fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT,
+                    Arrays.asList(new File(System.getProperty("user.dir"))));
+            for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
+                //for each source, compile and check against annotations
+                new BridgeHarness(jfo).compileAndCheck();
+            }
+            //if there were errors, fail
+            if (nerrors > 0) {
+                throw new AssertionError("Errors were found");
+            }
+        } finally {
+            fm.close();
         }
     }