Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e2bbae0

Browse files
author
Igor Tarasov
authoredMar 18, 2020
Let JVM print an exception and a backtrace of the stack. (#53)
1 parent 385dede commit e2bbae0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed
 

‎include/jni/errors.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ namespace jni
6666

6767
inline void CheckJavaException(JNIEnv& env)
6868
{
69-
if (env.ExceptionCheck()) throw PendingJavaException();
69+
if (env.ExceptionCheck()) {
70+
env.ExceptionDescribe();
71+
throw PendingJavaException();
72+
}
7073
}
7174

7275
inline void CheckJavaExceptionThenErrorCode(JNIEnv& env, jint err)

‎test/android/jni.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ struct _JNIEnv {
532532
{ return functions->ExceptionOccurred(this); }
533533

534534
void ExceptionDescribe()
535-
{ functions->ExceptionDescribe(this); }
535+
{ if (functions->ExceptionDescribe) functions->ExceptionDescribe(this); }
536536

537537
void ExceptionClear()
538538
{ functions->ExceptionClear(this); }

‎test/openjdk/jni.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ struct JNIEnv_ {
825825
return functions->ExceptionOccurred(this);
826826
}
827827
void ExceptionDescribe() {
828-
functions->ExceptionDescribe(this);
828+
if (functions->ExceptionDescribe) functions->ExceptionDescribe(this);
829829
}
830830
void ExceptionClear() {
831831
functions->ExceptionClear(this);

0 commit comments

Comments
 (0)
Please sign in to comment.