This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[Patch] New throw test
- From: David Daney <ddaney at avtrex dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 02 Nov 2006 15:21:48 -0800
- Subject: [Patch] New throw test
I preperation for hacking on MIPS signal handling changes, I wrote this
test.
As indicated in the comments in the test, I am checking that unwinding
is working properly if the very first instruction of a method faults.
The test code does this for MIPS. But as far as I can tell, it is
impossible to generate code that falults on the first instruction for
i686 so the test passes there as well.
In any event it was unclear if any existing test covered this case so I
would like to add it.
Manually tested on mipsel-linux and i686-pc-linux-gnu, Full make -k
check in libjava running on i686-pc-linux-gnu.
OK to commit if it passes?
2006-11-02 David Daney <ddaney@avtrex.com>
* testsuite/libjava.lang/Throw_3.java: New Test.
* testsuite/libjava.lang/Throw_3.out: Its expected output.
Index: testsuite/libjava.lang/Throw_3.java
===================================================================
--- testsuite/libjava.lang/Throw_3.java (revision 0)
+++ testsuite/libjava.lang/Throw_3.java (revision 0)
@@ -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;
+ }
+}
Index: testsuite/libjava.lang/Throw_3.out
===================================================================
--- testsuite/libjava.lang/Throw_3.out (revision 0)
+++ testsuite/libjava.lang/Throw_3.out (revision 0)
@@ -0,0 +1 @@
+ok