-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
A common pattern through JNI code that is present in this project is to perform the following two APIs within a JNI method:
value = (*env)->GetPrimitiveArrayCritical(env, methodvariable, &isCopy);
...
if (value != NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, methodvariable, value, 0);
}
In these cases where the value being referenced is only used as input during processing we should instead be using JNI_ABORT instead of the value 0 in the call to ReleasePrimitiveArrayCritical.
The value 0 indicates that a copy of the value is to be made back to the java object. In many cases what we intend here, for read only values, is the JNI method to use the value JNI_ABORT. This may improve performance since excessive copies could be avoided in these cases.
Metadata
Metadata
Assignees
Labels
No labels