Native methods are a significant security risk to Java programs. The C runtime system has no protection against array bounds errors, indirection through bad pointers, and so on. It is particularly important that programmers of native methods handle all error conditions to preserve the integrity of the Java platform. In particular, when your native method diagnoses a problem that it cannot handle, it should report this problem to the Java virtual machine.
Normally, you would throw an exception in this situation. However, C has no exceptions. Instead, you must call the
ThrowNew function to create a new exception object. When the native method exits, the Java virtual machine throws that exception.
To use the