langtools/test/tools/javac/T6900149.java
changeset 27319 030080f03e4f
parent 16800 3267051107a1
child 30730 d3ce7619db2c
--- a/langtools/test/tools/javac/T6900149.java	Wed Oct 29 12:09:17 2014 +0100
+++ b/langtools/test/tools/javac/T6900149.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
@@ -37,14 +37,15 @@
         DiagnosticCollector<JavaFileObject> diag =
                 new DiagnosticCollector<JavaFileObject>();
         JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-        StandardJavaFileManager fm =
-                compiler.getStandardFileManager(null, null, null);
-        File emptyFile = createTempFile("Empty.java");
-        File[] files = new File[] { emptyFile, emptyFile };
-        CompilationTask task = compiler.getTask(null, fm, diag,
-                null, null, fm.getJavaFileObjects(files));
-        if (! task.call()) {
-            throw new AssertionError("compilation failed");
+        try (StandardJavaFileManager fm =
+                compiler.getStandardFileManager(null, null, null)) {
+            File emptyFile = createTempFile("Empty.java");
+            File[] files = new File[] { emptyFile, emptyFile };
+            CompilationTask task = compiler.getTask(null, fm, diag,
+                    null, null, fm.getJavaFileObjects(files));
+            if (! task.call()) {
+                throw new AssertionError("compilation failed");
+            }
         }
     }