Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 55 additions & 6 deletions _android/calls/InstanceCaller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ namespace jh
{
static jobject call(JNIEnv* env, jobject instance, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallObjectMethod(instance, javaMethod, arguments...);
jobject r = env->CallObjectMethod(instance, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
env->DeleteLocalRef(r);
return nullptr;
}
return r;
}
};

Expand All @@ -58,6 +66,12 @@ namespace jh
static void call(JNIEnv* env, jobject instance, jmethodID javaMethod, ArgumentTypes ... arguments)
{
env->CallVoidMethod(instance, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return;
}
}
};

Expand All @@ -69,7 +83,14 @@ namespace jh
{
static jboolean call(JNIEnv* env, jobject instance, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallBooleanMethod(instance, javaMethod, arguments...);
jboolean r = env->CallBooleanMethod(instance, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return false;
}
return r;
}
};

Expand All @@ -81,7 +102,14 @@ namespace jh
{
static jint call(JNIEnv* env, jobject instance, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallIntMethod(instance, javaMethod, arguments...);
jint r = env->CallIntMethod(instance, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0;
}
return r;
}
};

Expand All @@ -93,7 +121,14 @@ namespace jh
{
static jlong call(JNIEnv* env, jobject instance, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallLongMethod(instance, javaMethod, arguments...);
jlong r = env->CallLongMethod(instance, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0;
}
return r;
}
};

Expand All @@ -105,7 +140,14 @@ namespace jh
{
static jfloat call(JNIEnv* env, jobject instance, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallFloatMethod(instance, javaMethod, arguments...);
jfloat f = env->CallFloatMethod(instance, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0.0;
}
return f;
}
};

Expand All @@ -117,7 +159,14 @@ namespace jh
{
static jdouble call(JNIEnv* env, jobject instance, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallDoubleMethod(instance, javaMethod, arguments...);
jdouble d = env->CallDoubleMethod(instance, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0.0;
}
return d;
}
};

Expand Down
61 changes: 55 additions & 6 deletions _android/calls/StaticCaller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ namespace jh
{
static jobject call(JNIEnv* env, jclass javaClass, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallStaticObjectMethod(javaClass, javaMethod, arguments...);
jobject r = env->CallStaticObjectMethod(javaClass, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
env->DeleteLocalRef(r);
return nullptr;
}
return r;
}
};

Expand All @@ -61,6 +69,12 @@ namespace jh
static void call(JNIEnv* env, jclass javaClass, jmethodID javaMethod, ArgumentTypes ... arguments)
{
env->CallStaticVoidMethod(javaClass, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return;
}
}
};

Expand All @@ -72,7 +86,14 @@ namespace jh
{
static jboolean call(JNIEnv* env, jclass javaClass, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallStaticBooleanMethod(javaClass, javaMethod, arguments...);
jboolean r = env->CallStaticBooleanMethod(javaClass, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return false;
}
return r;
}
};

Expand All @@ -84,7 +105,14 @@ namespace jh
{
static jint call(JNIEnv* env, jclass javaClass, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallStaticIntMethod(javaClass, javaMethod, arguments...);
jint r = env->CallStaticIntMethod(javaClass, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0;
}
return r;
}
};

Expand All @@ -96,7 +124,14 @@ namespace jh
{
static jlong call(JNIEnv* env, jclass javaClass, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallStaticLongMethod(javaClass, javaMethod, arguments...);
jlong r = env->CallStaticLongMethod(javaClass, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0;
}
return r;
}
};

Expand All @@ -108,7 +143,14 @@ namespace jh
{
static jfloat call(JNIEnv* env, jclass javaClass, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallStaticFloatMethod(javaClass, javaMethod, arguments...);
jfloat r = env->CallStaticFloatMethod(javaClass, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0.0;
}
return r;
}
};

Expand All @@ -120,7 +162,14 @@ namespace jh
{
static jdouble call(JNIEnv* env, jclass javaClass, jmethodID javaMethod, ArgumentTypes ... arguments)
{
return env->CallStaticDoubleMethod(javaClass, javaMethod, arguments...);
jdouble r = env->CallStaticDoubleMethod(javaClass, javaMethod, arguments...);
jthrowable exception = env->ExceptionOccurred();
if (exception != nullptr) {
env->ExceptionDescribe();
env->ExceptionClear();
return 0.0;
}
return r;
}
};

Expand Down