jMethodID method_getValue = m_env->GetMethodID(native_object,"getValue","()Ljava/lang/String;");
这里,native_object应该是MyClass的类定义对象(jclass)
jmethodID GetMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig);
而到这里:
result = m_env->CallObjectMethod(native_object, method_getValue);
NativeType CallMethod(JNIEnv *env, jobject obj,
jmethodID 方法ID, ...);
您的 CallObjectMethod 需要 MyClass 中的对象作为第一个参数,而不是 jclass。http://download.oracle.com/javase/1.4.2/docs/guide/jni/spec/functions.html http://download.oracle.com/javase/1.4.2/docs/guide/jni/spec/functions.html
所以这里的任何一个调用都是错误的......
可能是 getMethodID...你绝对应该检查那里的 NULL 。
cheers,