handleJvmException
Convenient way to write
pendingException?.let { throwable ->
// ...
}Content copied to clipboard
There are two ways to handle an exception in native code:
The native method can choose to return immediately, causing the exception to be thrown in the Java code that initiated the native method call.
The native code can clear the exception by calling clearException, and then execute its own exception-handling code.
After an exception has been raised, the native code must first clear the exception before making other JNI calls. When there is an exception being thrown, the JNI functions that are safe to call are:
J<Type>Array.releaseElements