1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| static jfieldID f_name1_id = nullptr; static jfieldID f_name2_id = nullptr; static jfieldID f_name3_id = nullptr; static jfieldID f_name4_id = nullptr; static jfieldID f_name5_id = nullptr; static jfieldID f_name6_id = nullptr;
extern "C" JNIEXPORT void JNICALL Java_com_jack_as_1jni_1project_MainActivity2_initStaticCache(JNIEnv *env, jclass clazz) { f_name1_id = env->GetStaticFieldID(clazz, "name1", "Ljava/lang/String;"); f_name2_id = env->GetStaticFieldID(clazz, "name2", "Ljava/lang/String;"); f_name3_id = env->GetStaticFieldID(clazz, "name3", "Ljava/lang/String;"); f_name4_id = env->GetStaticFieldID(clazz, "name4", "Ljava/lang/String;"); f_name5_id = env->GetStaticFieldID(clazz, "name5", "Ljava/lang/String;"); f_name6_id = env->GetStaticFieldID(clazz, "name6", "Ljava/lang/String;"); }
extern "C" JNIEXPORT void JNICALL Java_com_jack_as_1jni_1project_MainActivity2_staticCache(JNIEnv *env, jclass clazz, jstring name) { env->SetStaticObjectField(clazz, f_name1_id, name); env->SetStaticObjectField(clazz, f_name2_id, name); env->SetStaticObjectField(clazz, f_name3_id, name); env->SetStaticObjectField(clazz, f_name4_id, name); env->SetStaticObjectField(clazz, f_name5_id, name); env->SetStaticObjectField(clazz, f_name6_id, name); }
extern "C" JNIEXPORT void JNICALL Java_com_jack_as_1jni_1project_MainActivity2_clearStaticCache(JNIEnv *env, jclass clazz) { f_name1_id = nullptr; f_name2_id = nullptr; f_name3_id = nullptr; f_name4_id = nullptr; f_name5_id = nullptr; f_name6_id = nullptr; }
|