MCPcopy Create free account
hub / github.com/antvis/F2Native / AttachCurrentThread

Function AttachCurrentThread

core/android/JNIUtil.cpp:24–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22JavaVM *GetJVM() { return g_jvm; }
23
24JNIEnv *AttachCurrentThread() {
25 JNIEnv *env = nullptr;
26
27 JavaVMAttachArgs args;
28 args.version = JNI_VERSION_1_4;
29 args.name = nullptr;
30 args.group = nullptr;
31 args.name = std::to_string(gettid()).data();
32
33 jint ret = g_jvm->AttachCurrentThread(&env, &args);
34 // LOGI("AttachCurrentThread:name=%s,ret=%d", (args.name == nullptr ? "[null]" : args.name), ret);
35 assert(JNI_OK == ret);
36 return env;
37}
38
39/**
40 * Get a JNIEnv* valid for this thread, regardless of whether

Callers 2

GetJniEnvSafeFunction · 0.85
JNI_OnLoadFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected