diff --git a/ReactAndroid/src/main/jni/xreact/jni/ModuleRegistryHolder.cpp b/ReactAndroid/src/main/jni/xreact/jni/ModuleRegistryHolder.cpp index a37191d15..7fb73011a 100644 --- a/ReactAndroid/src/main/jni/xreact/jni/ModuleRegistryHolder.cpp +++ b/ReactAndroid/src/main/jni/xreact/jni/ModuleRegistryHolder.cpp @@ -163,10 +163,6 @@ class NewJavaNativeModule : public NativeModule { std::vector methodDescriptors_; MethodCallResult invokeInner(ExecutorToken token, unsigned int reactMethodId, folly::dynamic&& params) { - if (!params.isArray()) { - throw std::invalid_argument( - folly::to("method parameters should be array, but are ", params.typeName())); - } return methods_[reactMethodId].invoke(instance_, module_.get(), token, params); } }; diff --git a/ReactCommon/cxxreact/CxxNativeModule.cpp b/ReactCommon/cxxreact/CxxNativeModule.cpp index dee9bd5e8..cb711c6f5 100644 --- a/ReactCommon/cxxreact/CxxNativeModule.cpp +++ b/ReactCommon/cxxreact/CxxNativeModule.cpp @@ -163,20 +163,7 @@ MethodCallResult CxxNativeModule::callSerializableNativeHook( " is asynchronous but invoked synchronously")); } - if (!args.isString()) { - throw std::invalid_argument( - folly::to("method parameters should be string, but are ", args.typeName())); - } - - folly::dynamic params = folly::parseJson(args.stringPiece()); - - if (!params.isArray()) { - throw std::invalid_argument( - folly::to("parsed method parameters should be array, but are ", - args.typeName())); - } - - return { method.syncFunc(std::move(params)), false }; + return { method.syncFunc(std::move(args)), false }; } } diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp index a748c63c3..14cd25664 100644 --- a/ReactCommon/cxxreact/JSCExecutor.cpp +++ b/ReactCommon/cxxreact/JSCExecutor.cpp @@ -264,7 +264,6 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) { installNativeHook<&JSCExecutor::nativeStartWorker>("nativeStartWorker"); installNativeHook<&JSCExecutor::nativePostMessageToWorker>("nativePostMessageToWorker"); installNativeHook<&JSCExecutor::nativeTerminateWorker>("nativeTerminateWorker"); - installNativeHook<&JSCExecutor::nativeCallSyncHook>("nativeCallSyncHook"); installGlobalFunction(m_context, "nativeLoggingHook", JSNativeHooks::loggingHook); installGlobalFunction(m_context, "nativePerformanceNow", JSNativeHooks::nowHook); @@ -867,13 +866,18 @@ JSValueRef JSCExecutor::nativeCallSyncHook( unsigned int moduleId = Value(m_context, arguments[0]).asUnsignedInteger(); unsigned int methodId = Value(m_context, arguments[1]).asUnsignedInteger(); - std::string argsJson = Value(m_context, arguments[2]).toJSONString(); + folly::dynamic args = folly::parseJson(Value(m_context, arguments[2]).toJSONString()); + + if (!args.isArray()) { + throw std::invalid_argument( + folly::to("method parameters should be array, but are ", args.typeName())); + } MethodCallResult result = m_delegate->callSerializableNativeHook( *this, moduleId, methodId, - argsJson); + std::move(args)); if (result.isUndefined) { return Value::makeUndefined(m_context); }