New<PrimitiveType>Array Routines - NewBooleanArray
ArrayType New<PrimitiveType>Array
(JNIEnv *env, jsize length);
A family of operations used to construct a new primitive array object. Table 4-8 describes the specific primitive array constructors. You should replace New<PrimitiveType>Array with one of the actual primitive array constructor routine names from the following table, and replace ArrayType with the corresponding array type for that routine.
Table 4-8a New<PrimitiveType>Array Family of Array Constructors
LINKAGE:
Indices in the JNIEnv interface function table.
Table 4-8b New<PrimitiveType>Array Family of Array Constructors
New<PrimitiveType>Array Routines
|
Index
|
---|---|
NewBooleanArray() |
175
|
NewByteArray() |
176
|
NewCharArray() |
177
|
NewShortArray() |
178
|
NewIntArray() |
179
|
NewLongArray() |
180
|
NewFloatArray() |
181
|
NewDoubleArray() |
182
|
PARAMETERS of NewBooleanArray
env
: the JNI interface pointer.length
: the array length.RETURNS of NewBooleanArray
Returns a Java array, or
Example of NewBooleanArrayNULL
if the array cannot be constructed.
EDIT: This is how I convert the
boolean
array to unsigned char
in C: jboolean *element = (*env)->GetBooleanArrayElements(env,chosen_packet,0);
for(j = 0; j < sz; j++)
src_pkt[j] = (unsigned char)element[j];
This src_pkt is acted upon and then I convert it back to
jboolean
.
EDIT2: This is how I convert the unsigned char array back to jboolean:
jbooleanArray arr = (*env)->NewBooleanArray(env,sz);
(*env)->SetBooleanArrayRegion(env,arr,0,sz,src_pkts);
(*env)->DeleteLocalRef(env,arr);