JNIEXPORT jint JNICALL Java_org_bing_testjni_MainActivity_Add
(JNIEnv *env, jobject obj, jint a, jint b)
{
while (true){
//反射调用java代码
jclass cls = env->FindClass("org/bing/testjni/MainActivity");
if (cls == NULL) {
break;
}
jmethodID ShowMsg = env->GetMethodID(cls, "ShowMsg", "()V");
if (ShowMsg == NULL) {
break;
}
// 调用构造初始化
// jmethodID init = env->GetMethodID(cls, "<init>", "()V");
// jobject obj1 = env->NewObject(cls, init);
env->CallVoidMethod(obj, ShowMsg);
break;
}
return a + b;
}