Add a unit test for ReferenceMap that involves try-catch-finally.
Stress test the ReferenceMap when the program may have out-of-bound
exception.
Change-Id: Iec892d9564c501794571a7c52519ac539a792d6e
diff --git a/test/ReferenceMap/ReferenceMap.java b/test/ReferenceMap/ReferenceMap.java
new file mode 100644
index 0000000..5904d02
--- /dev/null
+++ b/test/ReferenceMap/ReferenceMap.java
@@ -0,0 +1,33 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+
+public class ReferenceMap {
+ public ReferenceMap() {
+ }
+
+ Object f() {
+ Object x[] = new Object[2];
+ Object y = null;
+ try {
+ y = new Object();
+ x[2] = y; // out-of-bound exception
+ } catch(Exception ex) {
+ if (y == null) {
+ x[1] = new Object();
+ }
+ } finally {
+ x[1] = y;
+ refmap(0);
+ };
+ return y;
+ }
+ native int refmap(int x);
+
+ static {
+ System.loadLibrary("arttest");
+ }
+
+ public static void main(String[] args) {
+ ReferenceMap rm = new ReferenceMap();
+ rm.f();
+ }
+}