| 10 | static JavaVM* g_jvm = NULL; |
| 11 | |
| 12 | static 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 | |
| 39 | static void fiber_thread_run(fiber_waiter* waiter) { |
| 40 | waiter->start(1024000); |
no test coverage detected
searching dependent graphs…