我正在尝试创建一个对象的实例,该实例具有一个构造函数,该构造函数通过将整数作为 jvalue 数组的成员传递来获取两个整数。当我从构造函数打印参数时,似乎只有第一个参数被正确传递,为什么会这样?我的 C 和 Java 代码如下。
C代码
jclass theClass;
jmethodID theMethod;
theClass = (*env)->FindClass(env, "thepackage/TwoNumbers");
theMethod = (*env)->GetMethodID(env, theClass, "<init>", "(II)V");
jvalue args[2];
args[0].i=55;
args[1].i=6;
jobject theObj = (*env)->NewObject(env, theClass, theMethod, *args);
Java 代码
package thepackage;
public class TwoNumbers {
int a;
int b;
TwoNumbers(int first, int second) {
this.a=first;
this.b=second;
System.out.println("A is "+first+" and b is "+second);
}
}