Describe exception handling in JNI

Describe exception handling in JNI.

- JNI exceptions can be handled by using C++ exception handling. Using throw and catch blocks of C++ and invoking those methods through JNI is one of the solutions. JNI has built in functions for handling exceptions, which is a better choice.

The following methods can be used for handling exceptions:

throw() : An exception object is thrown. It is used in native method for rethrowing an exception

throwNew() : Creates a new object of an exception and throws it.

exceptionDescribe() : The stack trace and the exception will be printed.

exceptionOccurred() : It is used for determining whether an exception is thrown.

exceptionClear() : A pending exception will be cleared.

fatalError() : A fatal error is raised and does not return anything.
Advantages and disadvantages of using JNI
Developers can take the advantage of Java platform. Legacy code investments need not be abandoned, Interoperability issues can be addressed..
What is JTA?
What is JTA? - Java Transaction API is a standard between the transaction manager and the entities participated in the distributed transaction system...
What is bean managed transaction?
What is bean managed transaction? - A bean managed transaction is an explicitly bounded for a specific transaction that is handled by a bean...
Post your comment