How to obtain a description of a Java exception in C++ when using JNI?

前端 未结 3 534
慢半拍i
慢半拍i 2021-02-02 12:30

I would like to determine what exception has been thrown by a Java function when calling that function from C++ code using JNI. I have the following code that catches the Java

3条回答
  •  醉话见心
    2021-02-02 13:08

    If you are just interested in the stack trace of the exception you can:

    if (env->ExceptionOccurred()) // check if an exception occurred
    {
        env->ExceptionDescribe(); // print the stack trace          
    }
    

提交回复
热议问题