Throw pending JNI errors after Java method discovery in TM

Summary: I was trying to debug an issue with a method signature mismatch last week, but was having trouble figuring out the problem because the error I was getting was unrelated - apparently JNI will sometimes swallow the error and just fail mysteriously later on. Ramanpreet showed me this macro that will throw any pending exceptions, so let's do that after we try to lookup the Java method in case it fails.

Reviewed By: RSNara

Differential Revision: D17680121

fbshipit-source-id: 1f23e49014f7cc1616e111386d440637e6a74677
This commit is contained in:
Emily Janzer
2019-10-02 12:03:13 -07:00
committed by Facebook Github Bot
parent da8ae011bb
commit 7a6478465d
@@ -446,6 +446,10 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
jmethodID methodID =
env->GetMethodID(cls, methodName.c_str(), methodSignature.c_str());
// If the method signature doesn't match, show a redbox here instead of
// crashing later.
FACEBOOK_JNI_THROW_PENDING_EXCEPTION();
// TODO(T43933641): Refactor to remove this special-casing
if (methodName == "getConstants") {
auto constantsMap = (jobject)env->CallObjectMethod(instance, methodID);