无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

零聲大學(xué)生春招秋招Linux C/C++開發(fā)就業(yè)

2022-09-23 20:03 作者:janet19961217  | 我要投稿

JNIEnv

這個(gè)是JNIEnv是可以用來新建Java對(duì)象實(shí)例并調(diào)用對(duì)象方法的。值得注意的地方有兩個(gè):

  1. 這個(gè)JNIEnv必須每次調(diào)用時(shí)都要重新獲取。

  2. 在C環(huán)境下創(chuàng)建的子線程中,獲取JNIEnv必須要AttachCurrentThread
    例子如下:

JNIEnv *NZJNI_GetEnv(){ ? ?JNIEnv *env = nullptr; ? ?if (g_javavm) { ? ? ? ?if (g_javavm->GetEnv((void **)(&env), JNI_VERSION_1_6) != JNI_OK) { ? ? ? ? ? ?NZLOGE("NZJNI_GetEnv can't get the enviroument"); ? ? ? ?} ? ?} else { ? ? ? ?NZLOGE("NZJNI_GetEnv null javavm"); ? ?} ? ?return env;}JNIEnv *NZJNI_AttachCurrentThread(){ ? ?JNIEnv *env = nullptr; ? ?if (g_javavm) { ? ? ? ?if (g_javavm->AttachCurrentThread(&env, nullptr) != JNI_OK) { ? ? ? ? ? ?NZLOGE("NZJNI_AttachCurrentThread can't get the enviroument"); ? ? ? ?} ? ?} else { ? ? ? ?NZLOGE("NZJNI_AttachCurrentThread null javavm"); ? ?} ? ?return env;}JNIEnv *NZJNI_AutoAttachAndGetEnv(bool *newAttached){ ? ?JNIEnv *env = nullptr; ? ?if (g_javavm) { ? ? ? ?jint result = g_javavm->GetEnv((void **) (&env), JNI_VERSION_1_6); ? ? ? ?if (result == JNI_OK) { ? ? ? ? ? ?*newAttached = false; ? ? ? ? ? ?return env; ? ? ? ?} else if (result == JNI_EDETACHED) { ? ? ? ? ? ?if (g_javavm->AttachCurrentThread(&env, nullptr) == JNI_OK) { ? ? ? ? ? ? ? ?*newAttached = true; ? ? ? ? ? ? ? ?return env; ? ? ? ? ? ?} else { ? ? ? ? ? ? ? ?NZLOGE("NZJNI_AutoAttachAndGetEnv can't AttachCurrentThread "); ? ? ? ? ? ? ? ?*newAttached = false; ? ? ? ? ? ? ? ?return env; ? ? ? ? ? ?} ? ? ? ?} else { ? ? ? ? ? ?NZLOGE("NZJNI_AutoAttachAndGetEnv can't GetEnv"); ? ? ? ? ? ?*newAttached = false; ? ? ? ? ? ?return env; ? ? ? ?} ? ?} else { ? ? ? ?NZLOGE("NZJNI_AutoAttachAndGetEnv null javavm"); ? ? ? ?return env; ? ?}}void NZJNI_DetachCurrentThread(){ ? ?if (g_javavm) { ? ? ? ?if (g_javavm->DetachCurrentThread() != JNI_OK) { ? ? ? ? ? ?NZLOGE("NZJNI_DetachCurrentThread failure"); ? ? ? ?} ? ?} else { ? ? ? ?NZLOGE("NZJNI_DetachCurrentThread null javavm"); ? ?}}



零聲大學(xué)生春招秋招Linux C/C++開發(fā)就業(yè)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
合川市| 长顺县| 社旗县| 龙游县| 克什克腾旗| 高陵县| 阿鲁科尔沁旗| 和田市| 宜昌市| 黔东| 察哈| 贡觉县| 噶尔县| 巴青县| 金塔县| 西安市| 吉水县| 长丰县| 林口县| 秦皇岛市| 综艺| 宾川县| 屯昌县| 广昌县| 长治市| 麦盖提县| 河东区| 云梦县| 阿城市| 苗栗市| 辰溪县| 平湖市| 克拉玛依市| 察雅县| 玛曲县| 青州市| 观塘区| 巨野县| 墨玉县| 南投县| 大埔区|