This is a two part question. My first question relates to boolean values in the C portion of a JNI implementation. Since C doesn't have a boolean type, I am confused about how to do this. I have a Java object that looks like this:
public class JNIResult {
private boolean successful;
private String data;
public JNIResult(boolean successful, String data) {
this.successful = successful;
this.data = data;
}
}
On the C side, I want to create a new JNIResult
object. I have gotten the constructor method ID, and now I am calling (*env)->NewObject()
. Let's say, for instance, that I want to create this object:
JNIResult(true, null);
How would I do that in C? I know that it would be something like this:
jobject JNIResult = (*env)->NewObject(env, JNIResultClass, JNIResultConstructor, true, NULL);
but the boolean thing is confusing me.
Secondly, stemming from that question, when supplying parameters to a native Java method in C, whether it's a constructor or another method, what should the type be for those values? For instance, if I am calling a Java square root function that takes a double
value as an argument, on the C side should I supply a jdouble
or a double
value to the function?