This code is copied directly from http://java.sun.com/docs/books/jni/html/objtypes.html#4013
JNIEXPORT jstring JNICALL
Java_Prompt_getLine(JNIEnv *env, jobject obj, jstring prompt)
{
char buf[128];
const jbyte *str;
str = (*env)->GetStringUTFChars(env, prompt, NULL);
if (str == NULL) {
return NULL; /* OutOfMemoryError already thrown */
}
printf("%s", str);
(*env)->ReleaseStringUTFChars(env, prompt, str);
/* We assume here that the user does not type more than
* 127 characters */
scanf("%s", buf);
return (*env)->NewStringUTF(env, buf);
}
Why is it neither
env->GetStringUTFChars(...
nor
(*env).GetStringUTFChars(...
?
From earlier in the document you linked in your question:
Reading this it seems that
JNIEnvis itself a pointer. It’s even a nice picture describing the relationships below the paragraph.