aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-02-16 22:39:36 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-02-16 22:39:36 +0000
commit5b0d59b4e7e9102fdce92787a05f1ad982d7eddd (patch)
tree749456485a5c02cd5067b92fbfbf8829ed248eff /libjava
parentb32369e675a8e6d6d295d081c6e0f09d1d509124 (diff)
downloadgcc-5b0d59b4e7e9102fdce92787a05f1ad982d7eddd.zip
gcc-5b0d59b4e7e9102fdce92787a05f1ad982d7eddd.tar.gz
gcc-5b0d59b4e7e9102fdce92787a05f1ad982d7eddd.tar.bz2
throwit.java: New file.
* libjava.jni/throwit.java: New file. * libjava.jni/throwit.c: New file. * libjava.jni/throwit.out: New file. From-SVN: r32016
Diffstat (limited to 'libjava')
-rw-r--r--libjava/testsuite/ChangeLog6
-rw-r--r--libjava/testsuite/libjava.jni/throwit.c25
-rw-r--r--libjava/testsuite/libjava.jni/throwit.java33
-rw-r--r--libjava/testsuite/libjava.jni/throwit.out4
4 files changed, 68 insertions, 0 deletions
diff --git a/libjava/testsuite/ChangeLog b/libjava/testsuite/ChangeLog
index 0a70d71..44d9a6d 100644
--- a/libjava/testsuite/ChangeLog
+++ b/libjava/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2000-02-16 Tom Tromey <tromey@cygnus.com>
+
+ * libjava.jni/throwit.java: New file.
+ * libjava.jni/throwit.c: New file.
+ * libjava.jni/throwit.out: New file.
+
2000-02-15 Tom Tromey <tromey@cygnus.com>
* libjava.jni/findclass.java: New file
diff --git a/libjava/testsuite/libjava.jni/throwit.c b/libjava/testsuite/libjava.jni/throwit.c
new file mode 100644
index 0000000..0b02459
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/throwit.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+#include <throwit.h>
+
+void
+Java_throwit_throwit (JNIEnv *env, jclass klass, jstring name,
+ jboolean is_new)
+{
+ const char *buf = (*env)->GetStringUTFChars (env, name, NULL);
+ jclass k = (*env)->FindClass (env, buf);
+ (*env)->ReleaseStringUTFChars (env, name, buf);
+
+ if (k == NULL || (*env)->ExceptionCheck (env))
+ return;
+
+ if (is_new)
+ (*env)->ThrowNew (env, k, "the word is zardoz");
+ else
+ {
+ jmethodID id = (*env)->GetMethodID (env, k, "<init>",
+ "(Ljava.lang.String;)V");
+ jstring z = (*env)->NewStringUTF (env, "zardoz is the word");
+ jobject obj = (*env)->NewObject (env, k, id, z);
+ (*env)->Throw (env, obj);
+ }
+}
diff --git a/libjava/testsuite/libjava.jni/throwit.java b/libjava/testsuite/libjava.jni/throwit.java
new file mode 100644
index 0000000..459622d
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/throwit.java
@@ -0,0 +1,33 @@
+// Test to see if throw works.
+
+public class throwit
+{
+ static
+ {
+ System.loadLibrary ("throwit");
+ }
+
+ public static native void throwit (String name, boolean is_new);
+
+ public static void main (String[] args)
+ {
+ try
+ {
+ throwit ("java/lang/UnknownError", false);
+ }
+ catch (Throwable x)
+ {
+ System.out.println (x.getClass ());
+ System.out.println (x.getMessage ());
+ }
+ try
+ {
+ throwit ("java/lang/Throwable", true);
+ }
+ catch (Throwable x)
+ {
+ System.out.println (x.getClass ());
+ System.out.println (x.getMessage ());
+ }
+ }
+}
diff --git a/libjava/testsuite/libjava.jni/throwit.out b/libjava/testsuite/libjava.jni/throwit.out
new file mode 100644
index 0000000..8c75e99
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/throwit.out
@@ -0,0 +1,4 @@
+class java.lang.UnknownError
+the word is zardoz
+class java.lang.Throwable
+zardoz is the word