The Java Native InterfaceProgrammer’s Guide and Specification phần 10 pdf

30 398 0
The Java Native InterfaceProgrammer’s Guide and Specification phần 10 pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

JNI FUNCTIONS Release<Type>ArrayElements 275 Linkage Indices in the JNIEnv interface function table. Parameters env: the JNIEnv interface pointer. array: a reference to an array object. elems: a pointer to array elements. mode: the release mode. Exceptions None. Release<Type>ArrayElements Index ReleaseBooleanArrayElements 191 ReleaseByteArrayElements 192 ReleaseCharArrayElements 193 ReleaseShortArrayElements 194 ReleaseIntArrayElements 195 ReleaseLongArrayElements 196 ReleaseFloatArrayElements 197 ReleaseDoubleArrayElements 198 jni.book Page 275 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ReleasePrimitiveArrayCritical JNI FUNCTIONS 276 ReleasePrimitiveArrayCritical Prototype void ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode); Description Informs the virtual machine implementation that native code no longer needs access to carray, the result of a previous GetPrimitiveArrayCritical call. If necessary, this function copies back all changes made to carray to the original array. The mode argument provides information on how the array buffer should be released. The mode argument has no effect if carray is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table: In most cases, programmers pass 0 to the mode argument to ensure consistent behavior for copied arrays. The other options give the programmer more control over memory management and should be used with extreme care. This function was introduced in Java 2 SDK release 1.2. Linkage Index 223 in the JNIEnv interface function table. Parameters env: the JNIEnv interface pointer. array: a reference to an array object. carray: a pointer to array elements. mode: the release mode. Exceptions None. Mode Actions 0 copy back and free the carray buffer JNI_COMMIT copy back but do not free the carray buffer JNI_ABORT free the buffer without copying back the possible changes in the carray buffer jni.book Page 276 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com JNI FUNCTIONS ReleaseStringChars 277 ReleaseStringChars Prototype void ReleaseStringChars(JNIEnv *env, jstring string, const jchar *chars); Description Informs the virtual machine implementation that native code no longer needs access to chars. The chars argument is a pointer obtained from string using GetStringChars. Linkage Index 166 in the JNIEnv interface function table. Parameters env: the JNIEnv interface pointer. string: a reference to a string object. chars: a pointer to a Unicode string. Exceptions None. jni.book Page 277 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ReleaseStringCritical JNI FUNCTIONS 278 ReleaseStringCritical Prototype void ReleaseStringCritical(JNIEnv *env, jstring string, const jchar *carray); Description Informs the virtual machine implementation that native code no longer needs access to carray. The carray argument is a pointer obtained from string using GetStringCritical. In a code segment enclosed by GetStringCritical and ReleaseStringCritical calls, native code must not issue arbi- trary JNI calls or cause the current thread to block and wait for another thread in the virtual machine instance. This function was introduced in Java 2 SDK release 1.2. Linkage Index 225 in the JNIEnv interface function table. Parameters env: the JNIEnv interface pointer. string: a reference to a string object. chars: a pointer to a Unicode string. Exceptions None. jni.book Page 278 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com JNI FUNCTIONS ReleaseStringUTFChars 279 ReleaseStringUTFChars Prototype void ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf); Description Informs the virtual machine implementation that native code no longer needs access to the native string utf. The utf argument is a pointer derived from string using GetStringUTFChars. Linkage Index 169 in the JNIEnv interface function table. Parameters env: the JNIEnv interface pointer. string: a reference to a string object. utf: a pointer to a UTF-8 string. Exceptions None. jni.book Page 279 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Set<Type>ArrayRegion JNI FUNCTIONS 280 Set<Type>ArrayRegion Prototype void Set<Type>ArrayRegion(JNIEnv *env, <ArrayType> array, jsize start, jsize len, <NativeType> *buf); Forms This family of functions consists of eight members. Description Copies back a region of a primitive array from a buffer. The array reference and buf buffer must not be NULL. Linkage Indices in the JNIEnv interface function table. Set<Type>ArrayRegion <ArrayType> <NativeType> SetBooleanArrayRegion jbooleanArray jboolean SetByteArrayRegion jbyteArray jbyte SetCharArrayRegion jcharArray jchar SetShortArrayRegion jshortArray jshort SetIntArrayRegion jintArray jint SetLongArrayRegion jlongArray jlong SetFloatArrayRegion jfloatArray jfloat SetDoubleArrayRegion jdoubleArray jdouble Set<Type>ArrayRegion Index SetBooleanArrayRegion 207 SetByteArrayRegion 208 SetCharArrayRegion 209 SetShortArrayRegion 210 SetIntArrayRegion 211 SetLongArrayRegion 212 SetFloatArrayRegion 213 SetDoubleArrayRegion 214 jni.book Page 280 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com JNI FUNCTIONS Set<Type>ArrayRegion 281 Parameters env: the JNIEnv interface pointer. array: a reference to a primitive array to which the elements are copied. start: the starting index in the primitive array. len: the number of elements to be copied. buf: the source buffer. Exceptions ArrayIndexOutOfBoundsException: if one of the indices in the region is not valid. jni.book Page 281 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Set<Type>Field JNI FUNCTIONS 282 Set<Type>Field Prototype void Set<Type>Field(JNIEnv *env, jobject obj, jfieldID fieldID, <NativeType> value); Forms This family of functions consists of nine members. Description Sets the value of an instance field of an object. The obj refer- ence must not be NULL. Linkage Indices in the JNIEnv interface function table. Set<Type>Field <NativeType> SetObjectField jobject SetBooleanField jboolean SetByteField jbyte SetCharField jchar SetShortField jshort SetIntField jint SetLongField jlong SetFloatField jfloat SetDoubleField jdouble Set<Type>Field Index SetObjectField 104 SetBooleanField 105 SetByteField 106 SetCharField 107 SetShortField 108 SetIntField 109 SetLongField 110 SetFloatField 111 SetDoubleField 112 jni.book Page 282 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com JNI FUNCTIONS Set<Type>Field 283 Parameters env: the JNIEnv interface pointer. obj: a reference to an object. fieldID: a field ID. value: the new value of the field. Exceptions None. jni.book Page 283 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com SetObjectArrayElement JNI FUNCTIONS 284 SetObjectArrayElement Prototype void SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject value); Description Sets an element of an Object array. The array reference must not be NULL. Linkage Index 174 in the JNIEnv interface function table. Parameters env: the JNIEnv interface pointer. array: a reference to an array whose element will be accessed. index: index of the array element to be accessed. value: the new value of the array element. Exceptions ArrayIndexOutOfBoundsException:ifindex does not specify a valid index in the array. ArrayStoreException: if the class of value is not a subclass of the element class of the array. jni.book Page 284 Thursday, February 21, 2002 4:36 PM Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com [...]... 270 java. class.path property, 85 java. io.FileDescriptor, 124 java. lang.Class, 202 java. lang.ClassLoader, 202 java. lang.Float, 121 java. lang.Integer, 121 java. lang.reflect package, 105 java. lang.reflect.Constructor, 105 , 217 java. lang.reflect.Field, 105 , 216 java. lang.reflect.Method, 105 , 217 java. lang.String See String java. lang.Thread, 48 property, 17, 150 java. library.path Java/ Java call, 58 Java/ native. .. IsInstanceOf, 105 , 247 IsSameObject, 66, 158, 248 297 Simpo PDF Merge FebruarySplit Unregistered Version - http://www.simpopdf.com jni.book Page 298 Thursday, and 21, 2002 4:36 PM INDEX J Java_ jarray, 166, 167 Java 2 SDK, 8 Java API See Java Application Programming Interface Java application, 4 See also native application Java Application Programming Interface, 4 Java Core Reflection API, 161 Java Development... the specified class with the message specified by message and causes that exception to be thrown Linkage Index 14 in the JNIEnv interface function table Parameters env: the JNIEnv interface pointer clazz: a subclass of java. lang.Throwable message: the message used to construct the java. lang.Throwable object Return Values Exceptions 288 Returns zero on success; otherwise, returns a negative value if the. .. UnregisterNatives UnregisterNatives Prototype jint UnregisterNatives(JNIEnv *env, jclass clazz); Description Unregisters native methods of a class The class goes back to the state before it was linked or registered with its native method functions This function should not be used in normal native code Instead, it provides special programs a way to reload and relink native libraries Linkage Index 216 in the. .. Returns an instance of the java. lang.reflect.Method class or an instance of the java. lang.reflect.Constructor class; otherwise, returns NULL Returns NULL if and only if an invocation of this function has thrown an exception OutofMemoryError: if the system runs out of memory Simpo PDF Merge FebruarySplit Unregistered Version - http://www.simpopdf.com jni.book Page 291 Thursday, and 21, 2002 4:36 PM JNI... instance of the java. lang.reflect.Field class This function was introduced in Java 2 SDK release 1.2 Linkage Index 12 in the JNIEnv interface function table Parameters env: the JNIEnv interface pointer cls: a reference to a class or interface fieldID: a JNI field ID isStatic: whether the field ID denotes a static field Return Values Returns an instance of the java. lang.reflect.Field class; otherwise, returns... JNI_CreateJavaVM, 85, 249 javac Simpo PDF Merge FebruarySplit Unregistered Version - http://www.simpopdf.com jni.book Page 299 Thursday, and 21, 2002 4:36 PM INDEX JNI_EDETACHED constant, 172, 225 171 JNI_EVERSION constant, 172, 225 JNI_FALSE constant, 171 JNI_GetCreatedJavaVMs, 97, 254 JNI_GetDefaultJavaVMInitArgs, 85, 255 JNI_NativeMethod, 273 JNI_OK constant, 171 JNI_OnLoad, 97, 102 , 256 JNI_OnUnload, 104 ,... function prototype, 14 header files, 15 name encoding, 152 linking, 151 registering, 101 steps in writing and running, 11 native method interface, 7 See also Java Native Interface compatibility among releases, 8 problems in JDK 1.0, 7 native modifier, 13 native programming languages, 4 native thread model, 97 native /Java callback, 58 NewArray, 36, 266 NewBooleanArray, 266 NewByteArray, 266 NewCharArray,... java. lang.Thread, 48 property, 17, 150 java. library.path Java/ Java call, 58 Java/ native call, 58 298 prefix, 22 Java_ VMInitArgs, 251 compiler, 11, 14 javah tool, 9, 11, 14 javai.dll, 87 javai.lib, 87 javap tool, 44 JavaVM interface create, 83 destroy, 86 obtaining pointer to, 97 JavaVMAttachArgs, 182 JavaVMInitArgs, 85 JavaVMOption, 85 jboolean, 165 accidentally truncated, 132 jbooleanArray, 166, 167 jbyte, 165 jbyteArray,... Kit, 7 Java Native Interface, 3 alternative solutions, 6 benefits, 8 design goals, 145 function table, 22 functions, 22 implications of using, 6 performance characteristics, 58 role of, 4 version evolution, 155, 179 when to use, 6 Java platform, 4 See also host environment Java programming language, 3 Java Runtime Environment, 4 java runtime interpreter, 11, 83 Java virtual machine, 4 instance, 173 Java . jdouble Set<Type>Field Index SetObjectField 104 SetBooleanField 105 SetByteField 106 SetCharField 107 SetShortField 108 SetIntField 109 SetLongField 110 SetFloatField 111 SetDoubleField 112 jni.book. mode has the following impact, as shown in the following table: In most cases, programmers pass 0 to the mode argument to ensure consistent behavior for copied arrays. The other options give the programmer. elements. mode: the release mode. Exceptions None. Mode Actions 0 copy back and free the carray buffer JNI_COMMIT copy back but do not free the carray buffer JNI_ABORT free the buffer without copying back the possible

Ngày đăng: 13/08/2014, 08:20

Từ khóa liên quan

Mục lục

  • Preface

  • Introduction

  • Getting Started

  • Basic Types, Strings, and Arrays

  • Fields and Methods

  • Local and Global References

  • Exceptions

  • The Invocation Interface

  • Additional JNI Features

  • Leveraging Existing Native Libraries

  • Traps and Pitfalls

  • Overview of the JNI Design

  • JNI Types

  • JNI Functions

  • Index

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan