Be more verbose about JNI errors at least with --enable-dbgutil

("The Java Native Interface" by Sheng Liang, Addison-Wesley 1999, states on
page 211:  "This function [ExceptionDescribe] has the side effect of clearing
the pending exception."  And since Java 10, the documentation of
ExceptionDescription at <https://docs.oracle.com/javase/10/docs/specs/jni/
functions.html#exceptiondescribe> states that "[t]he pending exception is
cleared as a side-effect of calling this function", even though for Java 8
<https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#
ExceptionDescribe> does not mention that.  So assume that calling
ExceptionDescribe always makes calling ExceptionClear superfluous.)

Change-Id: I4f89eb44768d436a224d7027afb5e7a93f092f29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88050
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2020-02-05 17:34:10 +01:00
parent 6fe261ea09
commit 75c21f5a92

View file

@ -1582,7 +1582,11 @@ void JavaVirtualMachine::setUpUnoVirtualMachine(JNIEnv * environment) {
}
void JavaVirtualMachine::handleJniException(JNIEnv * environment) {
#if defined DBG_UTIL
environment->ExceptionDescribe();
#else
environment->ExceptionClear();
#endif
throw css::uno::RuntimeException(
"JNI exception occurred",
static_cast< cppu::OWeakObject * >(this));