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

前端 未结 3 531
慢半拍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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 13:17

    The easy way out of this is to declare the JNI method to throw all possible exceptions, then:

    jthrowable throwable = ExceptionOccurred(env);
    if (throwable != NULL)
       Throw(env, throwable);
    

    and let your Java code deal with it.

提交回复
热议问题