y-scope / clp-ffi-java

Apache License 2.0
10 stars 3 forks source link

Wrap all JNI method bodies to ensure C++ exceptions don't crash the JVM; Add better error handling for JNI methods. #34

Closed kirkrodrigues closed 1 year ago

kirkrodrigues commented 1 year ago

Description

The current code relies on developers to ensure that no exceptions are thrown from their code since unhandled exceptions will kill the JVM. This PR introduces macros which wrap every JNI method body to ensure most exceptions are caught and propagated to the JVM gracefully. Relying on exceptions also allows us to simplify a lot of error handling.

This PR also handles errors from JNI methods that were not handled before.

Validation performed

Validated all unit tests continue to pass.