The specification for GetString[UTF]Chars is ambiguous ( the Sheng Liang JNI book is at odds with the online specification ). It is not clear if there is a JNI pending exception if the function returns NULL.
To ensure that an exception is thrown the following pattern (or similar) needs to be used.
if (obj == NULL) {
if (!(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, NULL);
return NULL;
}
Since both out of memory and throwing exceptions is rare supplying extra code to check
for conditions that do not occur is wasteful.
Please clarify the JNI specification.