mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 12:15:37 +08:00
Fix multiple invocations of getConstants
Summary: `jclass` in `JNI` is just a regular local reference. Therefore, it's unsafe to keep a static reference to it. Link: http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/refs.html. This bug made it so that when you clicked on `getConstants` twice in the TurboModule playground, the app would crash. Reviewed By: mdvacca Differential Revision: D15174821 fbshipit-source-id: 13b2b8726473acc9b07306558044d26bed0db92d
This commit is contained in:
committed by
Facebook Github Bot
parent
c9006ce5fb
commit
a9650709e3
@@ -109,7 +109,7 @@ jsi::Value convertFromJMapToValue(JNIEnv *env, jsi::Runtime &rt, jobject arg) {
|
||||
// This could also be done purely in C++, but iterative over map methods
|
||||
// but those may end up calling reflection methods anyway
|
||||
// TODO (axe) Investigate the best way to convert Java Map to Value
|
||||
static jclass jArguments = env->FindClass("com/facebook/react/bridge/Arguments");
|
||||
jclass jArguments = env->FindClass("com/facebook/react/bridge/Arguments");
|
||||
static jmethodID jMakeNativeMap = env->GetStaticMethodID(jArguments, "makeNativeMap", "(Ljava/util/Map;)Lcom/facebook/react/bridge/WritableNativeMap;");
|
||||
auto constants = (jobject) env->CallStaticObjectMethod(jArguments, jMakeNativeMap, arg);
|
||||
auto jResult = jni::adopt_local(constants);
|
||||
|
||||
Reference in New Issue
Block a user