aboutsummaryrefslogtreecommitdiffstats
path: root/JNIHelp.cpp
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-04-10 20:34:39 -0700
committerJeff Brown <jeffbrown@google.com>2012-04-10 20:35:34 -0700
commite2b11e7e4077187462324810d2b8a404417ba6a2 (patch)
tree46117710b1ca6804330e9ea1ad3f44bd54dc601c /JNIHelp.cpp
parent9a67c9d55e573ea7c908b1863b568e2806697b41 (diff)
downloadandroid_libnativehelper-e2b11e7e4077187462324810d2b8a404417ba6a2.tar.gz
android_libnativehelper-e2b11e7e4077187462324810d2b8a404417ba6a2.tar.bz2
android_libnativehelper-e2b11e7e4077187462324810d2b8a404417ba6a2.zip
Make sure we rethrow the same exception we started with.
Bug: 6312938 Change-Id: I41d8adf27fd32103c55d9eeafa28a25c37f5029d
Diffstat (limited to 'JNIHelp.cpp')
-rw-r--r--JNIHelp.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/JNIHelp.cpp b/JNIHelp.cpp
index 7c0b146..bf50930 100644
--- a/JNIHelp.cpp
+++ b/JNIHelp.cpp
@@ -257,15 +257,16 @@ int jniThrowIOException(C_JNIEnv* env, int errnum) {
void jniLogException(C_JNIEnv* env, int priority, const char* tag, jthrowable exception) {
JNIEnv* e = reinterpret_cast<JNIEnv*>(env);
- scoped_local_ref<jthrowable> currentException(env);
+ scoped_local_ref<jthrowable> currentException(env, (*env)->ExceptionOccurred(e));
if (exception == NULL) {
- exception = (*env)->ExceptionOccurred(e);
+ exception = currentException.get();
if (exception == NULL) {
return;
}
+ }
+ if (currentException.get() != NULL) {
(*env)->ExceptionClear(e);
- currentException.reset(exception);
}
char* buffer = getStackTrace(env, exception);
@@ -278,7 +279,7 @@ void jniLogException(C_JNIEnv* env, int priority, const char* tag, jthrowable ex
free(buffer);
if (currentException.get() != NULL) {
- (*env)->Throw(e, exception); // rethrow
+ (*env)->Throw(e, currentException.get()); // rethrow
}
}