Wednesday, April 24, 2013

jni jnienv NewDoubleArray example c c++ java


New<PrimitiveType>Array Routines - NewDoubleArray


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.(NewDoubleArray)

Table 4-8a New<PrimitiveType>Array Family of Array Constructors

New<PrimitiveType>Array Routines

Array Type

NewBooleanArray()

jbooleanArray

NewByteArray()

jbyteArray

NewCharArray()

jcharArray

NewShortArray()

jshortArray

NewIntArray()

jintArray

NewLongArray()

jlongArray

NewFloatArray()

jfloatArray

NewDoubleArray()

jdoubleArray
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 NewDoubleArray

env: the JNI interface pointer.

length: the array length.

RETURNS of NewDoubleArray

Returns a Java array, or NULL if the array cannot be constructed.
Example of NewDoubleArray


jdoubleArray ret = env->NewDoubleArray(2);

jdouble* rotationsJ = (jdouble *) malloc(2*sizeof(jdouble));
rotationsJ[0] = 4.0; 
rotationsJ[1] = 4.0;

cout<<"Rotations 0..."<<rotationsJ[0];
env->SetDoubleArrayRegion(ret, 0, 2, (const jdouble*)rotationsJ);

return  ret;