summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-28 16:24:21 +0000
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-28 16:24:21 +0000
commit97c27f78de1b7874f7cb94ae4850b91ccb3e7173 (patch)
treed3d35181c68b12e84c59aba11b8cd7b86feec9db /libjava
parent226494a382d663c05017fcc4922273e874c384eb (diff)
downloadgcc-97c27f78de1b7874f7cb94ae4850b91ccb3e7173.tar.gz
2002-03-28 Andrew Haley <aph@redhat.com>
* libjava.lang/Throw_2.java: New. * libjava.lang/Throw_2.out: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51515 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/testsuite/ChangeLog5
-rw-r--r--libjava/testsuite/libjava.lang/Throw_2.java57
-rw-r--r--libjava/testsuite/libjava.lang/Throw_2.out0
3 files changed, 62 insertions, 0 deletions
diff --git a/libjava/testsuite/ChangeLog b/libjava/testsuite/ChangeLog
index ed5929b0ff7..89823c1fed6 100644
--- a/libjava/testsuite/ChangeLog
+++ b/libjava/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2002-03-28 Andrew Haley <aph@redhat.com>
+
+ * libjava.lang/Throw_2.java: New.
+ * libjava.lang/Throw_2.out: New.
+
2002-03-27 Anthony Green <green@redhat.com>
* libjava.lang/InvokeReturn.java: Modify test for targets
diff --git a/libjava/testsuite/libjava.lang/Throw_2.java b/libjava/testsuite/libjava.lang/Throw_2.java
new file mode 100644
index 00000000000..353ae974662
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/Throw_2.java
@@ -0,0 +1,57 @@
+// Check that NullPointerExceptions thrown from library code are
+// caught. This detects a number of failures that can be caused by
+// libgcj being built incorrectly. In particular, we ensure that a
+// SEGV in native (i.e. C++) code in libgcj is handled correctly.
+
+// Regrettably, we cannot guarantee that Double.parseDouble() will
+// always be native code, or that it will never be inlined. It could
+// be argued that we should add a method to libgcj that will be
+// guaranteed forever to be native, but I'm reluctant to add to the
+// library for the sole purpose of performing this test.
+
+public class Throw_2
+{
+ public static Throwable obj()
+ {
+ return null;
+ }
+
+ public static String str()
+ {
+ return null;
+ }
+
+ static double d;
+
+ public static void main (String[] args)
+ {
+ // This NullPointerException will, at the time of writing, be
+ // thrown from Java code in libgcj.
+ try
+ {
+ java.util.Vector v = new java.util.Vector (null);
+ System.out.println ("fail: no exception thrown");
+ }
+ catch (NullPointerException _)
+ {
+ }
+ catch (Throwable _)
+ {
+ System.out.println ("fail: " + _);
+ }
+ // This one will, at the time of writing, be thrown from C++
+ // code in libgcj.
+ try
+ {
+ d = Double.parseDouble(str());
+ System.out.println ("fail: no exception thrown");
+ }
+ catch (NullPointerException _)
+ {
+ }
+ catch (Throwable _)
+ {
+ System.out.println ("fail: " + _);
+ }
+ }
+}
diff --git a/libjava/testsuite/libjava.lang/Throw_2.out b/libjava/testsuite/libjava.lang/Throw_2.out
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/Throw_2.out