in-progress patch
This commit is contained in:
parent
de01bd4fc1
commit
bff2e9181f
57
jna-callback-exception.patch
Normal file
57
jna-callback-exception.patch
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
diff -ur jna-3.0.4-svn729/native/callback.c jna-3.0.4-svn729.orig/native/callback.c
|
||||||
|
--- jna-3.0.4-svn729/native/callback.c 2008-09-07 13:32:02.000000000 -0400
|
||||||
|
+++ jna-3.0.4-svn729.orig/native/callback.c 2008-10-21 00:05:24.000000000 -0400
|
||||||
|
@@ -119,6 +119,42 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
+call_thread_uncaught(JNIEnv *env)
|
||||||
|
+{
|
||||||
|
+ jthrowable e;
|
||||||
|
+ jclass threadCls;
|
||||||
|
+ jclass handlerCls;
|
||||||
|
+ jmethodID mid;
|
||||||
|
+ jobject threadObj;
|
||||||
|
+ jobject handler;
|
||||||
|
+
|
||||||
|
+ /* Get the exception */
|
||||||
|
+ e = (*env)->ExceptionOccurred(env);
|
||||||
|
+
|
||||||
|
+ /* Now clear it from JNI's point of view, holding our ref to it */
|
||||||
|
+ (*env)->ExceptionClear(env);
|
||||||
|
+
|
||||||
|
+ threadCls = (*env)->FindClass(env, "java/lang/Thread");
|
||||||
|
+ if (threadCls == NULL)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ mid = (*env)->GetMethodID(env, threadCls, "getCurrentThread",
|
||||||
|
+ "()Ljava/lang/Thread;");
|
||||||
|
+ threadObj = (*env)->CallStaticObjectMethod(env, threadCls, mid);
|
||||||
|
+ mid = (*env)->GetMethodID(env, threadCls, "getUncaughtExceptionHandler",
|
||||||
|
+ "()Ljava/lang/Thread$UncaughtExceptionHandler;");
|
||||||
|
+ handler = (*env)->CallObjectMethod(env, threadObj, mid);
|
||||||
|
+ if (handler == NULL)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ handlerCls = (*env)->GetObjectClass(env, handler);
|
||||||
|
+ mid = (*env)->GetMethodID(env, handlerCls, "uncaughtException",
|
||||||
|
+ "(Ljava/lang/Thread;Ljava/lang/Throwable;)V");
|
||||||
|
+
|
||||||
|
+ (*env)->CallObjectMethod(env, handler, mid, threadObj, e);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
callback_invoke(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbargs) {
|
||||||
|
jobject self;
|
||||||
|
|
||||||
|
@@ -140,7 +176,8 @@
|
||||||
|
}
|
||||||
|
result = (*env)->CallObjectMethod(env, self, cb->methodID, array);
|
||||||
|
if ((*env)->ExceptionCheck(env)) {
|
||||||
|
- fprintf(stderr, "JNA: uncaught exception in callback, continuing\n");
|
||||||
|
+ /* Toss it over to the current thread's uncaught handler */
|
||||||
|
+ call_thread_uncaught(env);
|
||||||
|
memset(resp, 0, cif->rtype->size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Only in jna-3.0.4-svn729.orig/native: callback.c~
|
Loading…
Reference in New Issue
Block a user