我是NDK和JNI的新手。我有一个包含2个uint64_t变量的结构,我想将它们作为一个jobject传递给java类。
Java类
public class MyClass {
private long mVar1;
private long mVar2;
public MyClass() {
}
public MyClass(final long mVAR1, final long mVar2) {
this.mVar1 = mVar1;
this.mVar2 = mVar2;
}
public long getVar1() {
return this.mVar1;
}
public long getVar2() {
return this.mVar2;
}
}
这是我的JNI
JNIEXPORT jobject JNICALL Java_my_class_getMyClass(JNIEnv * env, jobject jobj) {
clazz = env->FindClass("my/package/test/MyClass");
methodID = env->GetMethodID(clazz, "<init>", "(JJ)V");
return convertMyClass(env, test.getMyClass());
}
这是转换
jobject convertMyClass(JNIEnv * env, MyClass myClass) {
jobject jmyclass = env->NewObject(clazz, methodID);
return jmyclass;
}
如何向convertMyClass添加参数。