* testsuite/libjava.lang/Throw_3.java: New Test.
authordaney <daney@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Nov 2006 19:43:25 +0000 (19:43 +0000)
committerdaney <daney@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Nov 2006 19:43:25 +0000 (19:43 +0000)
* testsuite/libjava.lang/Throw_3.out: Its expected output.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119023 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/testsuite/libjava.lang/Throw_3.java [new file with mode: 0644]
libjava/testsuite/libjava.lang/Throw_3.out [new file with mode: 0644]

index 7ba71ca..ee11b27 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-20  David Daney  <ddaney@avtrex.com>
+
+       * testsuite/libjava.lang/Throw_3.java: New Test.
+       * testsuite/libjava.lang/Throw_3.out: Its expected output.
+
 2006-11-13  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * configure: Regenerated.
diff --git a/libjava/testsuite/libjava.lang/Throw_3.java b/libjava/testsuite/libjava.lang/Throw_3.java
new file mode 100644 (file)
index 0000000..5d9a2dc
--- /dev/null
@@ -0,0 +1,41 @@
+// Check that a NPE likely thrown from the first instruction of a
+// method (foo) is properly caught.
+public class Throw_3
+{
+  public static void main(String[] args)
+  {
+    Throw_3 al = new Throw_3();
+    try
+      {
+        al.foo(null);
+      }
+    catch (NullPointerException npe)
+      {
+        StackTraceElement ste[] = npe.getStackTrace();
+        StackTraceElement top = ste[0];
+        if ("foo".equals(top.getMethodName()))
+          {
+            System.out.println("ok");
+            return;
+          }
+      }
+    System.out.println("bad");
+  }
+
+  public int bar(int[] a)
+  {
+    System.out.println("Bar");
+    return 5;
+  }
+
+  /**
+   * If the second parameter ('this' being the first) is passed in a
+   * register, then the first machine instruction in foo is likely to
+   * fault when null is passed.
+   */
+  public int foo(int[] a)
+  {
+    int l = a.length;
+    return l + l;
+  }
+}
diff --git a/libjava/testsuite/libjava.lang/Throw_3.out b/libjava/testsuite/libjava.lang/Throw_3.out
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok