Helper function added to handle Java exceptions in native code

This commit is contained in:
Tobias Brunner
2012-08-13 11:00:25 +02:00
parent 95e9a12c28
commit 19567a5e3a
@@ -24,6 +24,7 @@
#define ANDROID_JNI_H_
#include <jni.h>
#include <library.h>
#define JNI_PACKAGE org_strongswan_android_logic
#define JNI_PACKAGE_STRING "org/strongswan/android/logic"
@@ -62,4 +63,21 @@ void androidjni_attach_thread(JNIEnv **env);
*/
void androidjni_detach_thread();
/**
* Handle exceptions thrown by a JNI call
*
* @param env JNIEnv
* @return TRUE if an exception was thrown
*/
static inline bool androidjni_exception_occurred(JNIEnv *env)
{
if ((*env)->ExceptionOccurred(env))
{ /* clear any exception, otherwise the VM is terminated */
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
return TRUE;
}
return FALSE;
}
#endif /** ANDROID_JNI_H_ @}*/