source: trunk/gcc/libjava/testsuite/libjava.jni/throwit.c

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 712 bytes
Line 
1#include <stdlib.h>
2#include <throwit.h>
3
4JNIEXPORT void JNICALL
5Java_throwit_throwit (JNIEnv *env, jclass klass, jstring name,
6 jboolean is_new)
7{
8 const char *buf = (*env)->GetStringUTFChars (env, name, NULL);
9 jclass k = (*env)->FindClass (env, buf);
10 (*env)->ReleaseStringUTFChars (env, name, buf);
11
12 if (k == NULL || (*env)->ExceptionCheck (env))
13 return;
14
15 if (is_new)
16 (*env)->ThrowNew (env, k, "the word is zardoz");
17 else
18 {
19 jmethodID id = (*env)->GetMethodID (env, k, "<init>",
20 "(Ljava.lang.String;)V");
21 jstring z = (*env)->NewStringUTF (env, "zardoz is the word");
22 jobject obj = (*env)->NewObject (env, k, id, z);
23 (*env)->Throw (env, obj);
24 }
25}
Note: See TracBrowser for help on using the repository browser.