Release<PrimitiveType>ArrayElements Routines - ReleaseDoubleArrayElements
void
Release<PrimitiveType>ArrayElements(JNIEnv *env,
ArrayType
array,
NativeType *elems, jint mode);
A family of functions that informs the VM that the native code no longer needs access to
elems
. The elems
argument is a pointer derived from array
using the corresponding Get<
PrimitiveType>
ArrayElements() function. If necessary, this function copies back all changes made to elems
to the original array. (ReleaseDoubleArrayElements)
The
mode
argument provides information on how the array buffer should be released. mode
has no effect if elems
is not a copy of the elements in array
. Otherwise, mode
has the following impact, as shown in the following table:
Table 4-10 Primitive Array Release Modes (ReleaseDoubleArrayElements)
mode
|
actions
|
---|---|
0 |
copy back the content and free the
elems buffer |
JNI_COMMIT |
copy back the content but do not free the
elems buffer |
JNI_ABORT |
free the buffer without copying back the possible changes
|
In most cases, programmers pass “0” to the
mode
argument to ensure consistent behavior for both pinned and copied arrays. The other options give the programmer more control over memory management and should be used with extreme care. (ReleaseDoubleArrayElements)
The next table describes the specific routines that comprise the family of primitive array disposers. You should make the following substitutions:
- Replace Release<PrimitiveType>ArrayElements with one of the actual primitive array disposer routine names from Table 4-11.
- Replace ArrayType with the corresponding array type.
- Replace NativeType with the corresponding native type for that routine.
Table 4-11a Release<PrimitiveType>ArrayElements Family of Array Routines
LINKAGE:
Indices in the JNIEnv interface function table.
Table 4-11b Release<PrimitiveType>ArrayElements Family of Array Routines
PARAMETERS of ReleaseDoubleArrayElements
env
: the JNI interface pointer.array
: a Java array object.elems
: a pointer to array elements.mode
: the release mode.
Example of ReleaseDoubleArrayElements
jdoubleArray in2 = env->NewDoubleArray(1000);
jboolean isCopy;
jdouble *elems2 = env->GetDoubleArrayElements(in2, &isCopy);
for(int i = 0; i < 1000; i++)
{
elems2[i] = (jdouble)inputArray[i];
}
env->ReleaseDoubleArrayElements(in2, elems2, 0);
elems2 = NULL;