jnipp: Catch and handle exception in object destructor

This commit is contained in:
Rylie Pavlik 2024-04-04 14:51:50 -05:00
parent 1a76677800
commit 2453c1b2de

View file

@ -306,9 +306,15 @@ namespace jni
Object::~Object() noexcept
{
JNIEnv* env = jni::env();
JNIEnv* env;
try {
env = jni::env();
} catch (const jni::InitializationException &) {
// Better be empty. Cannot do anything useful.
return;
}
if (_isGlobal)
if (_isGlobal && _handle != nullptr)
env->DeleteGlobalRef(_handle);
if (_class != nullptr)