create global ref properly in YogaJNIException

Summary:
##Changelog:
[Internal][Yoga] create global ref properly in YogaJNIException

Reviewed By: astreet

Differential Revision: D18775982

fbshipit-source-id: ee529d6178d40b5f887fa1327fe156fa466f154f
This commit is contained in:
Sidharth Guglani
2019-12-03 15:57:51 -08:00
committed by Facebook Github Bot
parent ac8eb111a9
commit 089095f532
3 changed files with 19 additions and 4 deletions

View File

@@ -96,6 +96,16 @@ ScopedGlobalRef<jobject> newGlobalRef(JNIEnv* env, jobject obj) {
return make_global_ref(result);
}
ScopedGlobalRef<jthrowable> newGlobalRef(JNIEnv* env, jthrowable obj) {
jthrowable result = static_cast<jthrowable>(env->NewGlobalRef(obj));
if (!result) {
logErrorMessageAndDie("Could not obtain global reference from object");
}
return make_global_ref(result);
}
} // namespace vanillajni
} // namespace yoga
} // namespace facebook