diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-04-10 20:34:39 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-04-10 20:35:34 -0700 |
commit | 51bb1c02c30b62e416c86b2f6985fe7ea3279603 (patch) | |
tree | 9968d916cddab3ad8901f75dd9d10663881110ef | |
parent | deb0790505e6b1d4dccd90fce48585d411f0f006 (diff) | |
download | dalvik-51bb1c02c30b62e416c86b2f6985fe7ea3279603.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 } } |