mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Support nullable returns NativeModule methods returning Boxed Primitives
Summary: Returning null from a NativeModule method that has a return type of `java.lang.Double` causes the program to crash. This diff instead makes that method call return `null` to JS. TurboModules already has this behaviour. Changelog: [Android][Fixed] - Support nullable returns NativeModule methods returning Boxed Primitives Reviewed By: PeteTheHeat Differential Revision: D18866872 fbshipit-source-id: 6049c4df6908f1d276c5674b7e06eb5e002a7976
This commit is contained in:
committed by
Facebook Github Bot
parent
16e8a35d42
commit
f57b0caaa4
@@ -223,6 +223,9 @@ MethodCallResult MethodInvoker::invoke(std::weak_ptr<Instance>& instance, alias_
|
||||
#define OBJECT_CASE(JNI_CLASS, ACTIONS) { \
|
||||
auto jobject = env->CallObjectMethodA(module.get(), method_, args); \
|
||||
throwPendingJniExceptionAsCppException(); \
|
||||
if (!jobject) { \
|
||||
return folly::dynamic(nullptr); \
|
||||
} \
|
||||
auto result = adopt_local(static_cast<JNI_CLASS::javaobject>(jobject)); \
|
||||
return folly::dynamic(result->ACTIONS()); \
|
||||
}
|
||||
@@ -230,6 +233,9 @@ MethodCallResult MethodInvoker::invoke(std::weak_ptr<Instance>& instance, alias_
|
||||
#define OBJECT_CASE_CASTING(JNI_CLASS, ACTIONS, RESULT_TYPE) { \
|
||||
auto jobject = env->CallObjectMethodA(module.get(), method_, args); \
|
||||
throwPendingJniExceptionAsCppException(); \
|
||||
if (!jobject) { \
|
||||
return folly::dynamic(nullptr); \
|
||||
} \
|
||||
auto result = adopt_local(static_cast<JNI_CLASS::javaobject>(jobject)); \
|
||||
return folly::dynamic(static_cast<RESULT_TYPE>(result->ACTIONS())); \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user