MCPcopy Create free account
hub / github.com/acl-dev/acl / get_env

Function get_env

android/samples/fiber/HttpFiber/src/main/cpp/Fiber.cpp:12–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10static JavaVM* g_jvm = NULL;
11
12static JNIEnv* get_env(void) {
13 JNIEnv* env;
14 int status = g_jvm->GetEnv((void**) &env, JNI_VERSION_1_6);
15 if (status == JNI_EDETACHED || env == NULL) {
16 log_info("get_env(%d): status=%d, %d, env=%p",
17 __LINE__, status, JNI_EDETACHED, env);
18
19 log_info("try call AttachCurrentThread to get env, jvm=%p", g_jvm);
20 //status = g_jvm->AttachCurrentThreadAsDaemon(&env, NULL);
21 status = g_jvm->AttachCurrentThread(&env, NULL);
22 if (status != JNI_OK || env == NULL) {
23 log_error("get_env: AttachCurrentThread failed");
24 return NULL;
25 }
26 log_info("get_env(%d): status=%d, env=%p", __LINE__, status, env);
27 }
28
29 if (env->ExceptionOccurred()) {
30 log_error("%d: some exception happened!", __LINE__);
31 env->ExceptionDescribe();
32 env->ExceptionClear();
33 }
34
35 log_info("get_env: get env=%p ok, status=%d", env, status);
36 return env;
37}
38
39static void fiber_thread_run(fiber_waiter* waiter) {
40 waiter->start(1024000);

Callers 3

fiber_thread_runFunction · 0.70
~myfiberMethod · 0.70
runMethod · 0.70

Calls 2

log_infoFunction · 0.70
log_errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…