日期:2014-05-20 浏览次数:20648 次
//操作java屬性
JNIEXPORT void JNICALL Java_com_jni_test_Lesson1_upPerson
(JNIEnv * env, jobject obj){
jclass clazz = (*env)->FindClass(env,"com/jni/test/Person");
jfieldID id_member = (*env)->GetFieldID(env,clazz, "age", "I");
jint number = (*env)->GetIntField(env,obj, id_member);
(*env)->SetIntField(env,obj, id_member, 20L);
jfieldID sex_number = (*env)->GetFieldID(env,clazz, "sex", "Ljava/lang/String;");
jstring sex = (*env)->GetObjectField(env,obj,sex_number);
sex=(*env)->NewStringUTF(env,"zhengwei");
(*env)->SetObjectField(env,obj,sex_number,sex);
}