catchthrow.c
来自「初期JAVA学习非常有用的资料。帮助深入了解API。特别是Applet。」· C语言 代码 · 共 31 行
C
31 行
#include <jni.h>#include "CatchThrow.h"JNIEXPORT void JNICALL Java_CatchThrow_catchThrow(JNIEnv *env, jobject obj){ jclass cls = (*env)->GetObjectClass(env, obj); jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); jthrowable exc; if (mid == 0) { return; } (*env)->CallVoidMethod(env, obj, mid); exc = (*env)->ExceptionOccurred(env); if (exc) { /* We don't do much with the exception, except that we print a debug message using ExceptionDescribe, clear it, and throw a new exception. */ jclass newExcCls; (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); if (newExcCls == 0) { /* Unable to find the new exception class, give up. */ return; } (*env)->ThrowNew(env, newExcCls, "thrown from C code"); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?