Wednesday, April 24, 2013

jni jnienv SetLongArrayRegion example c c++ java


Set<PrimitiveType>ArrayRegion Routines - SetLongArrayRegion


void Set<PrimitiveType>ArrayRegion(JNIEnv *env, ArrayType array, jsize start, jsize len, NativeType *buf); (SetLongArrayRegion)

A family of functions that copies back a region of a primitive array from a buffer.

The following table describes the specific primitive array element accessors. You should make the following replacements: (SetLongArrayRegion)
  • Replace Set<PrimitiveType>ArrayRegion with one of the actual primitive element accessor routine names from the table.
  • Replace ArrayType with the corresponding array type.
  • Replace NativeType with the corresponding native type for that routine.
    Table 4-13a Set<PrimitiveType>ArrayRegion Family of Array Accessor Routines


    Set<PrimitiveType>ArrayRegion Routine


    Array Type


    Native Type

    SetBooleanArrayRegion()

    jbooleanArray

    jboolean

    SetByteArrayRegion()

    jbyteArray

    jbyte

    SetCharArrayRegion()

    jcharArray

    jchar

    SetShortArrayRegion()

    jshortArray

    jshort

    SetIntArrayRegion()

    jintArray

    jint

    SetLongArrayRegion()

    jlongArray

    jlong

    SetFloatArrayRegion()

    jfloatArray

    jfloat

    SetDoubleArrayRegion()

    jdoubleArray

    jdouble
LINKAGE of SetLongArrayRegion
Indices in the JNIEnv interface function table.
Table 4-13b Set<PrimitiveType>ArrayRegion Family of Array Accessor Routines
Set<PrimitiveType>ArrayRegion Routine
Index
SetBooleanArrayRegion()
207
SetByteArrayRegion()
208
SetCharArrayRegion()
209
SetShortArrayRegion()
210
SetIntArrayRegion()
211
SetLongArrayRegion()
212
SetFloatArrayRegion()
213
SetDoubleArrayRegion()
214
PARAMETERS of SetLongArrayRegion
env: the JNI interface pointer.

array: a Java array.

start: the starting index.

len: the number of elements to be copied.

buf: the source buffer.
THROWS:
ArrayIndexOutOfBoundsException: if one of the indexes in the region is not valid.
Example of SetLongArrayRegion


        case 'J': {
            jlong* bufferArray = reinterpret_cast<jlong*>(AgentBase::GetMemoryManager()
                    .Allocate(sizeof(jlong)*values JDWP_FILE_LINE));
            AgentAutoFree scavenger(bufferArray JDWP_FILE_LINE);
            
            for (int i = 0; i < values; i++) {
                value = m_cmdParser->command.ReadUntaggedValue(jni, JDWP_TAG_LONG);
                JDWP_TRACE_DATA("SetValues: set: index=" << i
                    << ", value=(long)" << value.j);
                bufferArray[i] = value.j;
            }
            jni->SetLongArrayRegion(static_cast<jlongArray>(arrayObject), firstIndex, values, bufferArray);
            break;
        }