Posted By:
Alan_Li
Posted On:
Tuesday, July 23, 2002 10:32 AM
I have the following Sample.java: public class Sample { protected String protMethod(int x, double[] d) { System.out.println("protMethod got called."); return "1234"; } } I want to invoke it from sample.c with: ... mid = (*env)->GetMethodID(env, cls, "protMethod", "(I[D)Ljava/lang/String;"); if (mid == 0) { fprintf(stderr, "Can't find protMethod "); exit(1); } jda = (*env)->NewDoubleArray(env, 2); num = 4; fprintf(stderr, "got here "); jstr = (*env)->CallObjectMethod(env, cls, mid, num, jda); fpr
More>>
I have the following Sample.java:
public class Sample {
protected String protMethod(int x, double[] d) {
System.out.println("protMethod got called.");
return "1234";
}
}
I want to invoke it from sample.c with:
...
mid = (*env)->GetMethodID(env, cls, "protMethod", "(I[D)Ljava/lang/String;");
if (mid == 0) {
fprintf(stderr, "Can't find protMethod
");
exit(1);
}
jda = (*env)->NewDoubleArray(env, 2);
num = 4;
fprintf(stderr, "got here
");
jstr = (*env)->CallObjectMethod(env, cls, mid, num, jda);
fprintf(stderr, "%s", ((*env)->GetStringUTFChars(env, jstr, NULL)));
...
But all I get is "got here" but not the returned string and dies after that without giving me any indication of an error. However if I change the protMethod() from protected to private, it prints out the returned string too and continues just fine. Why is this? Btw, I'm using j2sdk v1.4.0_01.
Thanks.
<<Less