8008215: break in catch clause causes java.lang.VerifyError: Inconsistent stackmap
Reviewed-by: jlaskey, lagergren
--- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java Thu Feb 14 11:32:49 2013 -0400
+++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java Fri Feb 15 09:18:05 2013 +0100
@@ -1742,6 +1742,10 @@
// TRY tested in caller.
next();
+ // Container block needed to act as target for labeled break statements
+ final Block outer = newBlock();
+ pushControlNode(outer);
+
// Create try.
final TryNode tryNode = new TryNode(source, tryToken, Token.descPosition(tryToken), findControl(TryNode.class));
pushControlNode(tryNode);
@@ -1819,12 +1823,17 @@
tryNode.setCatchBlocks(catchBlocks);
tryNode.setFinallyBody(finallyStatements);
tryNode.setFinish(finish);
+ outer.setFinish(finish);
// Add try.
- block.addStatement(tryNode);
+ outer.addStatement(tryNode);
} finally {
popControlNode(tryNode);
+ restoreBlock();
+ popControlNode(outer);
}
+
+ block.addStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer));
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8008215.js Fri Feb 15 09:18:05 2013 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2013, 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.
+ */
+
+/**
+ * JDK-8008215 : break in catch clause causes java.lang.VerifyError: Inconsistent stackmap
+ *
+ * @test
+ * @run
+ */
+
+a: try {
+ print("try");
+ throw new Error();
+} catch (e) {
+ print("catch");
+ break a;
+ print("error");
+} finally {
+ print("finally");
+}
+print("done");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8008215.js.EXPECTED Fri Feb 15 09:18:05 2013 +0100
@@ -0,0 +1,4 @@
+try
+catch
+finally
+done