Add defensive check for result returned after JNI function calls
Summary: Added method which checks if value(methodId, fieldId, class ...) returned by JNI functions (getMethod, getField, getClass ...) is valid or not and throw exception if they are not valid ##Changelog: [Internal][Yoga] Add defensive check for result returned after JNI calls Reviewed By: astreet Differential Revision: D18745718 fbshipit-source-id: 2af26eda15fbe7834e1c9b274deeed4f106274ab
This commit is contained in:
committed by
Facebook Github Bot
parent
073f49d0d0
commit
ac8eb111a9
@@ -76,6 +76,19 @@ void assertNoPendingJniException(JNIEnv* env) {
|
||||
throw YogaJniException(throwable);
|
||||
}
|
||||
|
||||
void assertNoPendingJniExceptionIf(JNIEnv* env, bool condition) {
|
||||
if (!condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (env->ExceptionCheck() == JNI_TRUE) {
|
||||
assertNoPendingJniException(env);
|
||||
return;
|
||||
}
|
||||
|
||||
throw YogaJniException();
|
||||
}
|
||||
|
||||
} // namespace vanillajni
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
Reference in New Issue
Block a user