--- old/src/share/classes/com/sun/tools/javac/parser/JavacParser.java 2011-01-28 15:38:28.000000000 -0800 +++ new/src/share/classes/com/sun/tools/javac/parser/JavacParser.java 2011-01-28 15:38:27.000000000 -0800 @@ -1639,7 +1639,7 @@ * | WHILE ParExpression Statement * | DO Statement WHILE ParExpression ";" * | TRY Block ( Catches | [Catches] FinallyPart ) - * | TRY "(" ResourceSpecification ")" Block [Catches] [FinallyPart] + * | TRY "(" ResourceSpecification ";"opt ")" Block [Catches] [FinallyPart] * | SWITCH ParExpression "{" SwitchBlockStatementGroups "}" * | SYNCHRONIZED ParExpression Block * | RETURN [Expression] ";" @@ -2182,13 +2182,12 @@ ListBuffer defs = new ListBuffer(); defs.append(resource()); while (S.token() == SEMI) { - // All but last of multiple declarators subsume a semicolon + // All but last of multiple declarators must subsume a semicolon storeEnd(defs.elems.last(), S.endPos()); int semiColonPos = S.pos(); S.nextToken(); - if (S.token() == RPAREN) { // Illegal trailing semicolon + if (S.token() == RPAREN) { // Optional trailing semicolon // after last resource - error(semiColonPos, "try.resource.trailing.semi"); break; } defs.append(resource()); --- old/src/share/classes/com/sun/tools/javac/resources/compiler.properties 2011-01-28 15:38:29.000000000 -0800 +++ new/src/share/classes/com/sun/tools/javac/resources/compiler.properties 2011-01-28 15:38:28.000000000 -0800 @@ -298,9 +298,6 @@ compiler.err.try.resource.may.not.be.assigned=\ auto-closeable resource {0} may not be assigned -compiler.err.try.resource.trailing.semi=\ - illegal trailing semicolon in resources declaration - # 0: symbol compiler.err.multicatch.parameter.may.not.be.assigned=\ multi-catch parameter {0} may not be assigned --- old/test/tools/javac/TryWithResources/BadTwrSyntax.java 2011-01-28 15:38:29.000000000 -0800 +++ new/test/tools/javac/TryWithResources/BadTwrSyntax.java 2011-01-28 15:38:29.000000000 -0800 @@ -4,13 +4,18 @@ * @author Joseph D. Darcy * @summary Verify bad TWRs don't compile * @compile/fail -source 6 BadTwrSyntax.java - * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java + * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java */ import java.io.IOException; public class BadTwrSyntax implements AutoCloseable { public static void main(String... args) throws Exception { - // illegal semicolon ending resources + // illegal double semicolon ending resources + try(BadTwr twrflow = new BadTwr();;) { + System.out.println(twrflow.toString()); + } + + // but one semicolon is fine try(BadTwr twrflow = new BadTwr();) { System.out.println(twrflow.toString()); } --- old/test/tools/javac/TryWithResources/BadTwrSyntax.out 2011-01-28 15:38:30.000000000 -0800 +++ new/test/tools/javac/TryWithResources/BadTwrSyntax.out 2011-01-28 15:38:30.000000000 -0800 @@ -1,2 +1,7 @@ -BadTwrSyntax.java:14:42: compiler.err.try.resource.trailing.semi -1 error +BadTwrSyntax.java:14:43: compiler.err.illegal.start.of.type +BadTwrSyntax.java:14:44: compiler.err.expected: = +BadTwrSyntax.java:14:45: compiler.err.expected: ')' +BadTwrSyntax.java:14:47: compiler.err.expected: '{' +BadTwrSyntax.java:15:19: compiler.err.illegal.start.of.expr +BadTwrSyntax.java:15:23: compiler.err.expected: ';' +6 errors --- old/test/tools/javac/diags/examples/TryResourceTrailingSemi.java 2011-01-28 15:38:31.000000000 -0800 +++ /dev/null 2009-07-06 20:02:10.000000000 -0700 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.err.try.resource.trailing.semi - -class TryResoureTrailingSemi implements AutoCloseable { - public static void main(String... args) { - try(TryResoureTrailingSemi r = new TryResoureTrailingSemi();) { - System.out.println(r.toString()); - } - } - - @Override - public void close() {return;} -}