diff options
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | JNIHelp.c | 10 | ||||
-rw-r--r-- | include_jni/jni.h | 1 | ||||
-rw-r--r-- | include_platform_header_only/nativehelper/jni_macros.h | 2 |
4 files changed, 9 insertions, 5 deletions
@@ -43,6 +43,7 @@ cc_library_headers { host_supported: true, export_include_dirs: ["include_jni"], native_bridge_supported: true, + product_available: true, vendor_available: true, target: { windows: { @@ -100,14 +100,16 @@ static bool GetExceptionSummary(JNIEnv* env, jthrowable thrown, struct Expandabl (*env)->DeleteLocalRef(env, className); className = NULL; + bool success = false; jmethodID getMessage = FindMethod(env, "java/lang/Throwable", "getMessage", "()Ljava/lang/String;"); jstring message = (jstring) (*env)->CallObjectMethod(env, thrown, getMessage); - if (message == NULL) { - return true; + if (message != NULL) { + success = (ExpandableStringAppend(dst, ": ") && AppendJString(env, message, dst)); + } else if ((*env)->ExceptionOccurred(env) == NULL) { + success = true; } - bool success = (ExpandableStringAppend(dst, ": ") && AppendJString(env, message, dst)); if (!success) { // Two potential reasons for reaching here: // @@ -169,7 +171,7 @@ static bool GetStackTrace(JNIEnv* env, jthrowable thrown, struct ExpandableStrin FindMethod(env, "java/lang/Throwable", "printStackTrace", "(Ljava/io/PrintWriter;)V"); (*env)->CallVoidMethod(env, thrown, printStackTrace, pw); - jstring trace = StringWriterToString(env, sw); + jstring trace = ((*env)->ExceptionOccurred(env) != NULL) ? NULL : StringWriterToString(env, sw); (*env)->DeleteLocalRef(env, pw); pw = NULL; diff --git a/include_jni/jni.h b/include_jni/jni.h index 67417a5..8346ca4 100644 --- a/include_jni/jni.h +++ b/include_jni/jni.h @@ -771,6 +771,7 @@ struct _JNIEnv { CALL_STATIC_TYPE(jfloat, Float) CALL_STATIC_TYPE(jdouble, Double) + __attribute__((no_stack_protector)) void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...) { va_list args; diff --git a/include_platform_header_only/nativehelper/jni_macros.h b/include_platform_header_only/nativehelper/jni_macros.h index 79f23c8..ca03288 100644 --- a/include_platform_header_only/nativehelper/jni_macros.h +++ b/include_platform_header_only/nativehelper/jni_macros.h @@ -41,7 +41,7 @@ * JNINativeMethod[] gMethods = { * MAKE_JNI_NATIVE_METHOD("normal", "(I)Ljava/lang/Object;", KlassName_normal), * MAKE_JNI_FAST_NATIVE_METHOD("fast", "(I)Ljava/lang/Object;", KlassName_fast), - * MAKE_JNI_CRITICAL_NATIVE_METHOD("critical", "(Z)I", KlassName_critical), + * MAKE_JNI_CRITICAL_NATIVE_METHOD("critical", "(J)I", KlassName_critical), * }; * * // Automatically infer the signature: |