mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-25 20:40:29 +08:00
5b0d59b4e7
* libjava.jni/throwit.java: New file. * libjava.jni/throwit.c: New file. * libjava.jni/throwit.out: New file. From-SVN: r32016
26 lines
694 B
C
26 lines
694 B
C
#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);
|
|
}
|
|
}
|