diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-04-10 20:34:39 -0700 |
---|---|---|
committer | The Android Automerger <android-build@android.com> | 2012-04-11 17:22:56 -0700 |
commit | 3ca3a08391dc962ce8834c646d511dd35d49816b (patch) | |
tree | 9968d916cddab3ad8901f75dd9d10663881110ef | |
parent | c6f97abe8b5ffe7f7c47447e1d3dce2d8257e338 (diff) | |
download | dalvik-3ca3a08391dc962ce8834c646d511dd35d49816b.tar.gz |
Make sure we rethrow the same exception we started with.
Bug: 6312938
Change-Id: I41d8adf27fd32103c55d9eeafa28a25c37f5029d
-rw-r--r-- | libnativehelper/JNIHelp.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libnativehelper/JNIHelp.cpp b/libnativehelper/JNIHelp.cpp index 7c0b146d9..bf50930c3 100644 --- a/libnativehelper/JNIHelp.cpp +++ b/libnativehelper/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 } } |