langtools/test/tools/javac/tree/TreePosRoundsTest.java
changeset 27319 030080f03e4f
parent 6717 0103d76cfe48
child 27991 8f4b68523da3
--- a/langtools/test/tools/javac/tree/TreePosRoundsTest.java	Wed Oct 29 12:09:17 2014 +0100
+++ b/langtools/test/tools/javac/tree/TreePosRoundsTest.java	Wed Oct 29 17:25:23 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 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
@@ -54,18 +54,19 @@
         String testSrc = System.getProperty("test.src");
         String testClasses = System.getProperty("test.classes");
         JavaCompiler c = ToolProvider.getSystemJavaCompiler();
-        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
-        String thisName = TreePosRoundsTest.class.getName();
-        File thisFile = new File(testSrc, thisName + ".java");
-        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
-        List<String> options = Arrays.asList(
-                "-proc:only",
-                "-processor", thisName,
-                "-processorpath", testClasses);
-        CompilationTask t = c.getTask(null, fm, null, options, null, files);
-        boolean ok = t.call();
-        if (!ok)
-            throw new Exception("processing failed");
+        try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+            String thisName = TreePosRoundsTest.class.getName();
+            File thisFile = new File(testSrc, thisName + ".java");
+            Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+            List<String> options = Arrays.asList(
+                    "-proc:only",
+                    "-processor", thisName,
+                    "-processorpath", testClasses);
+            CompilationTask t = c.getTask(null, fm, null, options, null, files);
+            boolean ok = t.call();
+            if (!ok)
+                throw new Exception("processing failed");
+        }
     }
 
     Filer filer;
@@ -155,6 +156,9 @@
                 //System.err.println("  encl: " +enclKind);
                 if (enclKind == Tree.Kind.CLASS || enclKind == Tree.Kind.BLOCK)
                     expect += ";";
+                // t-w-r- adds implicit final: remove it
+                if (enclKind == Tree.Kind.TRY && expect.startsWith("final "))
+                    expect = expect.substring(6);
             }
             //System.err.println("expect: " + expect);