Signed-off-by: Tomek Grabiec <[email protected]>
---
Makefile | 1 +
regression/jvm/FinallyTest.java | 126 +++++++++++++++++++++++++++++++++++++++
regression/run-suite.sh | 1 +
3 files changed, 128 insertions(+), 0 deletions(-)
create mode 100644 regression/jvm/FinallyTest.java
diff --git a/Makefile b/Makefile
index 03f34aa..7fff0b1 100644
--- a/Makefile
+++ b/Makefile
@@ -226,6 +226,7 @@ REGRESSION_TEST_SUITE_CLASSES = \
regression/jvm/ExitStatusIsOneTest.class \
regression/jvm/ExitStatusIsZeroTest.class \
regression/jvm/FibonacciTest.class \
+ regression/jvm/FinallyTest.class \
regression/jvm/FloatArithmeticTest.class \
regression/jvm/GetstaticPatchingTest.class \
regression/jvm/IntegerArithmeticExceptionsTest.class \
diff --git a/regression/jvm/FinallyTest.java b/regression/jvm/FinallyTest.java
new file mode 100644
index 0000000..6119137
--- /dev/null
+++ b/regression/jvm/FinallyTest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2009 Tomasz Grabiec
+ *
+ * This file is released under the GPL version 2 with the following
+ * clarification and special exception:
+ *
+ * Linking this library statically or dynamically with other modules is
+ * making a combined work based on this library. Thus, the terms and
+ * conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under terms
+ * of your choice, provided that you also meet, for each linked independent
+ * module, the terms and conditions of the license of that module. An
+ * independent module is a module which is not derived from or based on
+ * this library. If you modify this library, you may extend this exception
+ * to your version of the library, but you are not obligated to do so. If
+ * you do not wish to do so, delete this exception statement from your
+ * version.
+ *
+ * Please refer to the file LICENSE for details.
+ */
+package jvm;
+
+/**
+ * @author Tomasz Grabiec
+ */
+public class FinallyTest extends TestCase {
+ public static int methodWithSingleFinallyBlock() {
+ while (true) {
+ try {
+ return 1;
+ } finally {
+ if (true)
+ break;
+ }
+ }
+
+ return 0;
+ }
+
+ public static void testSingleFinallyBlock() {
+ assertEquals(0, methodWithSingleFinallyBlock());
+ }
+
+ public static int methodWithNestedFinallyBlocks() {
+ boolean b = true;
+
+ try {
+ return 1;
+ } finally {
+ while (b) {
+ try {
+ return 2;
+ } finally {
+ if (b) {
+ break;
+ }
+ }
+ }
+
+ if (true)
+ return 0;
+ }
+ }
+
+ public static void testNestedFinallyBlocks() {
+ assertEquals(0, methodWithNestedFinallyBlocks());
+ }
+
+ public static void testLineNumberTableAfterInlining() {
+ Exception e = null;
+ boolean b = true;
+
+ try {
+ return;
+ } finally {
+ while (b) {
+ try {
+ return;
+ } finally {
+ if (b) {
+ e = new Exception();
+ break;
+ }
+ }
+ }
+
+ assertEquals(86, e.getStackTrace()[0].getLineNumber());
+ }
+ }
+
+ public static void testExceptionTableAfterInlining() {
+ boolean caught = false;
+ boolean caughtInFinally = false;
+ RuntimeException r1 = new RuntimeException();
+ RuntimeException r2 = new RuntimeException();
+
+ try {
+ throw r1;
+ } catch (Exception e) {
+ assertEquals(r1, e);
+ caught = true;
+ } finally {
+ try {
+ throw r2;
+ } catch (Exception e) {
+ assertEquals(r2, e);
+ caughtInFinally = true;
+ }
+ }
+
+ assertTrue(caughtInFinally);
+ assertTrue(caught);
+ }
+
+ public static void main(String args[]) {
+ testSingleFinallyBlock();
+ testNestedFinallyBlocks();
+ testLineNumberTableAfterInlining();
+ testExceptionTableAfterInlining();
+ }
+}
\ No newline at end of file
diff --git a/regression/run-suite.sh b/regression/run-suite.sh
index ed3442b..b6bacce 100755
--- a/regression/run-suite.sh
+++ b/regression/run-suite.sh
@@ -56,6 +56,7 @@ if [ -z "$CLASS_LIST" ]; then
run_java jvm.ExitStatusIsOneTest 1
run_java jvm.ExitStatusIsZeroTest 0
run_java jvm.FibonacciTest 0
+ run_java jvm.FinallyTest 0
run_java jvm.FloatArithmeticTest 0
run_java jvm.GetstaticPatchingTest 0
run_java jvm.IntegerArithmeticExceptionsTest 0
--
1.6.0.6
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel