| 27 | static jobject g_fiber = NULL; |
| 28 | |
| 29 | static JNIEnv* get_env(void) { |
| 30 | JNIEnv* env; |
| 31 | int status = g_jvm->GetEnv((void**) &env, JNI_VERSION_1_6); |
| 32 | if (status == JNI_EDETACHED || env == NULL) { |
| 33 | log_info("get_env: status=%d, %d, env=%p", |
| 34 | status, JNI_EDETACHED, env); |
| 35 | status = g_jvm->AttachCurrentThread(&env, NULL); |
| 36 | if (status != JNI_OK || env == NULL) { |
| 37 | log_error("get_env: AttachCurrentThread failed"); |
| 38 | return NULL; |
| 39 | } |
| 40 | log_info("get_env: status=%d, env=%p", status, env); |
| 41 | } |
| 42 | |
| 43 | if (env->ExceptionOccurred()) { |
| 44 | log_error("%d: some exception happened!", __LINE__); |
| 45 | env->ExceptionDescribe(); |
| 46 | env->ExceptionClear(); |
| 47 | return NULL; |
| 48 | } |
| 49 | |
| 50 | log_info("get_env: get env=%p ok, status=%d", env, status); |
| 51 | return env; |
| 52 | } |
| 53 | |
| 54 | static void test1(void) { |
| 55 | log_info("test1: jvm=%p", g_jvm); |