Class JNIExceptionWrapper
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.graalvm.jniutils.JNIExceptionWrapper
- All Implemented Interfaces:
Serializable
Wraps an exception thrown by a JNI call into HotSpot. If the exception propagates up to an native
image entry point, the exception is re-thrown in HotSpot.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic final classContext forJNIExceptionWrapper.ExceptionHandler. -
Method Summary
Modifier and TypeMethodDescriptionstatic JNI.JThrowablecreateHSException(JNI.JNIEnv env, Throwable original) Crates an exception in HotSpot representing the givenoriginalexception.static StackTraceElement[]mergeStackTraces(StackTraceElement[] hotSpotStackTrace, StackTraceElement[] nativeStackTrace, boolean originatedInHotSpot) static voidthrowInHotSpot(JNI.JNIEnv env, Throwable original) Throws an exception into HotSpot.static voidIf there is a pending JNI exception, this method wraps it in aJNIExceptionWrapper, clears the pending exception and throws theJNIExceptionWrapperwrapper.static voidwrapAndThrowPendingJNIException(JNI.JNIEnv env, JNIExceptionWrapper.ExceptionHandler exceptionHandler) If there is a pending JNI exception, this method wraps it in aJNIExceptionWrapper, clears the pending exception and throws theJNIExceptionWrapperwrapper.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Method Details
-
wrapAndThrowPendingJNIException
If there is a pending JNI exception, this method wraps it in aJNIExceptionWrapper, clears the pending exception and throws theJNIExceptionWrapperwrapper. TheJNIExceptionWrappermessage is composed of the JNI exception class name and the JNI exception message. For exception filtering or custom handling of JNI exceptions seewrapAndThrowPendingJNIException(JNIEnv, ExceptionHandler). -
wrapAndThrowPendingJNIException
public static void wrapAndThrowPendingJNIException(JNI.JNIEnv env, JNIExceptionWrapper.ExceptionHandler exceptionHandler) If there is a pending JNI exception, this method wraps it in aJNIExceptionWrapper, clears the pending exception and throws theJNIExceptionWrapperwrapper. TheJNIExceptionWrappermessage is composed of the JNI exception class name and the JNI exception message.- See Also:
-
throwInHotSpot
Throws an exception into HotSpot. Iforiginalis aJNIExceptionWrapperthe wrapped JNI exception is thrown. Otherwise a newRuntimeExceptionis thrown. TheRuntimeExceptionmessage is composed oforiginal.getClass().getName()andoriginal.getMessage(). The stack trace is result of merging theoriginal.getStackTrace()with the current execution stack in HotSpot.- Parameters:
env- theJNI.JNIEnvoriginal- an exception to be thrown in HotSpot
-
createHSException
Crates an exception in HotSpot representing the givenoriginalexception.- Parameters:
env- theJNI.JNIEnvoriginal- an exception to be created in HotSpot
-
mergeStackTraces
public static StackTraceElement[] mergeStackTraces(StackTraceElement[] hotSpotStackTrace, StackTraceElement[] nativeStackTrace, boolean originatedInHotSpot)
-