Class JNINativeInterface
- java.lang.Object
-
- org.lwjgl.system.jni.JNINativeInterface
-
public class JNINativeInterface extends java.lang.Object
Bindings to the Java Native Interface (JNI).The JNI is a native programming interface. It allows Java code that runs inside a Java Virtual Machine (VM) to interoperate with applications and libraries written in other programming languages, such as C, C++, and assembly.
The most important benefit of the JNI is that it imposes no restrictions on the implementation of the underlying Java VM. Therefore, Java VM vendors can add support for the JNI without affecting other parts of the VM. Programmers can write one version of a native application or library and expect it to work with all Java VMs supporting the JNI.
LWJGL: Only functions that can reasonably be called from Java are exposed.
-
-
Field Summary
Fields Modifier and Type Field and Description static int
JNI_ABORT
JNI_COMMITUsed inReleaseScalarArrayElements
.static int
JNI_EDETACHED
JNI_EEXIST
JNI_EINVAL
JNI_ENOMEM
JNI_ERR
JNI_EVERSIONPossible return values for JNI functions.static int
JNI_FALSE
jboolean constants.static int
JNI_OK
Possible return values for JNI functions.static int
JNI_TRUE
jboolean constants.static int
JNI_VERSION_1_1
JNI_VERSION_1_2
JNI_VERSION_1_4
JNI_VERSION_1_6
JNI_VERSION_1_8
JNI_VERSION_9JNI versions.static int
JNIGlobalRefType
JNIInvalidRefType
JNILocalRefType
JNIWeakGlobalRefTypejobjectRefType
: Return values fromJNINativeInterface.GetObjectRefType(java.lang.Object)
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static void
DeleteGlobalRef(long globalRef)
Deletes the global reference pointed to byglobalRef
.static void
DeleteWeakGlobalRef(long weakGlobalRef)
Delete the VM resources needed for the given weak global reference.static long
FromReflectedField(java.lang.reflect.Field field)
Converts aField
to a field ID.static long
FromReflectedMethod(java.lang.reflect.Method method)
Converts aMethod
orConstructor
object to a method ID.static java.nio.ByteBuffer
GetBooleanArrayElements(byte[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies a region of a primitive array into a buffer.static java.nio.ByteBuffer
GetByteArrayElements(byte[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies a region of a primitive array into a buffer.static java.nio.ShortBuffer
GetCharArrayElements(char[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)
Copies a region of a primitive array into a buffer.static long
GetDirectBufferAddress(java.nio.Buffer buf)
Fetches and returns the starting address of the memory region referenced by the given directjava.nio.Buffer
.static java.nio.DoubleBuffer
GetDoubleArrayElements(double[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)
Copies a region of a primitive array into a buffer.static java.nio.FloatBuffer
GetFloatArrayElements(float[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)
Copies a region of a primitive array into a buffer.static java.nio.IntBuffer
GetIntArrayElements(int[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)
Copies a region of a primitive array into a buffer.static int
GetJavaVM(PointerBuffer vm)
Returns the Java VM interface (used in the Invocation API) associated with the current thread.static java.nio.LongBuffer
GetLongArrayElements(long[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)
Copies a region of a primitive array into a buffer.static int
GetObjectRefType(java.lang.Object obj)
Returns the type of the object referred to by theobj
argument.static java.nio.ShortBuffer
GetShortArrayElements(short[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array.static void
GetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)
Copies a region of a primitive array into a buffer.static void
GetStringRegion(java.lang.String str, int start, java.nio.ByteBuffer buf)
Copieslen
number of Unicode characters beginning at offsetstart
to the given bufferbuf
.static void
GetStringUTFRegion(java.lang.String str, int start, int len, java.nio.ByteBuffer buf)
Translateslen
number of Unicode characters beginning at offset start into modified UTF-8 encoding and place the result in the given bufferbuf
.static int
GetVersion()
Returns the version of the native method interface.static java.nio.ByteBuffer
NewDirectByteBuffer(long address, long capacity)
Allocates and returns a directjava.nio.ByteBuffer
referring to the block of memory starting at the memory address address and extending capacity bytes.static long
NewGlobalRef(java.lang.Object obj)
Creates a new global reference to the object referred to by theobj
argument.static long
NewWeakGlobalRef(java.lang.Object obj)
Creates a new weak global reference.static int
RegisterNatives(java.lang.Class<?> targetClass, JNINativeMethod.Buffer methods)
Registers native methods with the class specified by thetargetClass
argument.static void
ReleaseBooleanArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
ReleaseByteArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
ReleaseCharArrayElements(char[] array, java.nio.ShortBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
ReleaseDoubleArrayElements(double[] array, java.nio.DoubleBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
ReleaseFloatArrayElements(float[] array, java.nio.FloatBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
ReleaseIntArrayElements(int[] array, java.nio.IntBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
ReleaseLongArrayElements(long[] array, java.nio.LongBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
ReleaseShortArrayElements(short[] array, java.nio.ShortBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
.static void
SetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies back a region of a primitive array from a buffer.static void
SetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies back a region of a primitive array from a buffer.static void
SetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)
Copies back a region of a primitive array from a buffer.static void
SetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)
Copies back a region of a primitive array from a buffer.static void
SetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)
Copies back a region of a primitive array from a buffer.static void
SetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)
Copies back a region of a primitive array from a buffer.static void
SetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)
Copies back a region of a primitive array from a buffer.static void
SetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)
Copies back a region of a primitive array from a buffer.static java.lang.reflect.Field
ToReflectedField(java.lang.Class<?> cls, long fieldID, boolean isStatic)
Converts a field ID derived fromcls
to aField
object.static java.lang.reflect.Method
ToReflectedMethod(java.lang.Class<?> cls, long methodID, boolean isStatic)
Converts a method ID derived fromcls
to aMethod
orConstructor
object.static int
UnregisterNatives(java.lang.Class<?> targetClass)
Unregisters native methods of a class.
-
-
-
Field Detail
-
JNI_VERSION_1_1, JNI_VERSION_1_2, JNI_VERSION_1_4, JNI_VERSION_1_6, JNI_VERSION_1_8, JNI_VERSION_9
JNI versions.
-
JNIInvalidRefType, JNILocalRefType, JNIGlobalRefType, JNIWeakGlobalRefType
jobjectRefType
: Return values fromJNINativeInterface.GetObjectRefType(java.lang.Object)
.Enum values:
-
JNI_COMMIT, JNI_ABORT
Used inReleaseScalarArrayElements
.
-
-
Method Detail
-
GetVersion
public static int GetVersion()
Returns the version of the native method interface.- Returns:
- the major version number in the higher 16 bits and the minor version number in the lower 16 bits
-
FromReflectedMethod
public static long FromReflectedMethod(java.lang.reflect.Method method)
Converts aMethod
orConstructor
object to a method ID.- Parameters:
method
-
-
FromReflectedField
public static long FromReflectedField(java.lang.reflect.Field field)
Converts aField
to a field ID.- Parameters:
field
-
-
ToReflectedMethod
public static java.lang.reflect.Method ToReflectedMethod(java.lang.Class<?> cls, long methodID, boolean isStatic)
Converts a method ID derived fromcls
to aMethod
orConstructor
object.- Parameters:
cls
-methodID
-isStatic
- must be set toTRUE
if the method ID refers to a static field, and # FALSE otherwise
-
ToReflectedField
public static java.lang.reflect.Field ToReflectedField(java.lang.Class<?> cls, long fieldID, boolean isStatic)
Converts a field ID derived fromcls
to aField
object.
-
NewGlobalRef
public static long NewGlobalRef(java.lang.Object obj)
Creates a new global reference to the object referred to by theobj
argument. Theobj
argument may be a global or local reference. Global references must be explicitly disposed of by callingJNINativeInterface.DeleteGlobalRef(long)
.- Parameters:
obj
- a global or local reference- Returns:
- a global reference, or
NULL
if the system runs out of memory
-
DeleteGlobalRef
public static void DeleteGlobalRef(long globalRef)
Deletes the global reference pointed to byglobalRef
.- Parameters:
globalRef
- a global reference
-
GetBooleanArrayElements
public static java.nio.ByteBuffer GetBooleanArrayElements(byte[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseBooleanArrayElements(byte[], java.nio.ByteBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseBooleanArrayElements(byte[], java.nio.ByteBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseBooleanArrayElements
public static void ReleaseBooleanArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetBooleanArrayElements(byte[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetByteArrayElements
public static java.nio.ByteBuffer GetByteArrayElements(byte[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseByteArrayElements(byte[], java.nio.ByteBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseByteArrayElements(byte[], java.nio.ByteBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseByteArrayElements
public static void ReleaseByteArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetByteArrayElements(byte[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetCharArrayElements
public static java.nio.ShortBuffer GetCharArrayElements(char[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseCharArrayElements(char[], java.nio.ShortBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseCharArrayElements(char[], java.nio.ShortBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseCharArrayElements
public static void ReleaseCharArrayElements(char[] array, java.nio.ShortBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetCharArrayElements(char[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetShortArrayElements
public static java.nio.ShortBuffer GetShortArrayElements(short[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseShortArrayElements(short[], java.nio.ShortBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseShortArrayElements(short[], java.nio.ShortBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseShortArrayElements
public static void ReleaseShortArrayElements(short[] array, java.nio.ShortBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetShortArrayElements(short[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetIntArrayElements
public static java.nio.IntBuffer GetIntArrayElements(int[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseIntArrayElements(int[], java.nio.IntBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseIntArrayElements(int[], java.nio.IntBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseIntArrayElements
public static void ReleaseIntArrayElements(int[] array, java.nio.IntBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetIntArrayElements(int[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetLongArrayElements
public static java.nio.LongBuffer GetLongArrayElements(long[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseLongArrayElements(long[], java.nio.LongBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseLongArrayElements(long[], java.nio.LongBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseLongArrayElements
public static void ReleaseLongArrayElements(long[] array, java.nio.LongBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetLongArrayElements(long[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetFloatArrayElements
public static java.nio.FloatBuffer GetFloatArrayElements(float[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseFloatArrayElements(float[], java.nio.FloatBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseFloatArrayElements(float[], java.nio.FloatBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseFloatArrayElements
public static void ReleaseFloatArrayElements(float[] array, java.nio.FloatBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetFloatArrayElements(float[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetDoubleArrayElements
public static java.nio.DoubleBuffer GetDoubleArrayElements(double[] array, java.nio.ByteBuffer isCopy)
Returns the body of the primitive array. The result is valid until theJNINativeInterface.ReleaseDoubleArrayElements(double[], java.nio.DoubleBuffer, int)
function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array untilJNINativeInterface.ReleaseDoubleArrayElements(double[], java.nio.DoubleBuffer, int)
is called.If
isCopy
is notNULL
, then*isCopy
is set toTRUE
if a copy is made; or it is set toFALSE
if no copy is made.- Parameters:
array
- the primitive arrayisCopy
- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULL
if the operation fails
-
ReleaseDoubleArrayElements
public static void ReleaseDoubleArrayElements(double[] array, java.nio.DoubleBuffer elems, int mode)
Informs the VM that the native code no longer needs access toelems
. Theelems
argument is a pointer derived from array using theJNINativeInterface.GetDoubleArrayElements(double[], java.nio.ByteBuffer)
function. If necessary, this function copies back all changes made to elems to the original array.The
mode
argument provides information on how the array buffer should be released.mode
has no effect ifelems
is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:mode actions 0 copy back the content and free the elems buffer COMMIT
copy back the content but do not free the elems buffer 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.
-
GetBooleanArrayRegion
public static void GetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetBooleanArrayRegion
public static void SetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
GetByteArrayRegion
public static void GetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetByteArrayRegion
public static void SetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
GetCharArrayRegion
public static void GetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetCharArrayRegion
public static void SetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
GetShortArrayRegion
public static void GetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetShortArrayRegion
public static void SetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
GetIntArrayRegion
public static void GetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetIntArrayRegion
public static void SetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
GetLongArrayRegion
public static void GetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetLongArrayRegion
public static void SetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
GetFloatArrayRegion
public static void GetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetFloatArrayRegion
public static void SetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
GetDoubleArrayRegion
public static void GetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)
Copies a region of a primitive array into a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the destination buffer
-
SetDoubleArrayRegion
public static void SetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)
Copies back a region of a primitive array from a buffer.- Parameters:
array
- a Java arraystart
- the starting indexbuf
- the source buffer
-
RegisterNatives
public static int RegisterNatives(java.lang.Class<?> targetClass, JNINativeMethod.Buffer methods)
Registers native methods with the class specified by thetargetClass
argument. The methods parameter specifies an array of JNINativeMethod structures that contain the names, signatures, and function pointers of the native methods. The name and signature fields of theJNINativeMethod
structure are pointers to modified UTF-8 strings. ThenMethods
parameter specifies the number of native methods in the array.- Parameters:
targetClass
-methods
- the native methods in the class- Returns:
- “0” on success; returns a negative value on failure
-
UnregisterNatives
public static int UnregisterNatives(java.lang.Class<?> targetClass)
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.
- Parameters:
targetClass
- a Java class object- Returns:
- “0” on success; returns a negative value on failure
-
GetJavaVM
public static int GetJavaVM(PointerBuffer vm)
Returns the Java VM interface (used in the Invocation API) associated with the current thread. The result is placed at the location pointed to by the second argument,vm
.- Parameters:
vm
- a pointer to where the result should be placed
-
GetStringRegion
public static void GetStringRegion(java.lang.String str, int start, java.nio.ByteBuffer buf)
Copieslen
number of Unicode characters beginning at offsetstart
to the given bufferbuf
.- Parameters:
str
-start
-buf
-
-
GetStringUTFRegion
public static void GetStringUTFRegion(java.lang.String str, int start, int len, java.nio.ByteBuffer buf)
Translateslen
number of Unicode characters beginning at offset start into modified UTF-8 encoding and place the result in the given bufferbuf
.- Parameters:
str
-start
-len
-buf
-
-
NewWeakGlobalRef
public static long NewWeakGlobalRef(java.lang.Object obj)
Creates a new weak global reference. ReturnsNULL
ifobj
refers to null, or if the VM runs out of memory. If the VM runs out of memory, anOutOfMemoryError
will be thrown.- Parameters:
obj
-
-
DeleteWeakGlobalRef
public static void DeleteWeakGlobalRef(long weakGlobalRef)
Delete the VM resources needed for the given weak global reference.- Parameters:
weakGlobalRef
-
-
NewDirectByteBuffer
public static java.nio.ByteBuffer NewDirectByteBuffer(long address, long capacity)
Allocates and returns a directjava.nio.ByteBuffer
referring to the block of memory starting at the memory address address and extending capacity bytes.Native code that calls this function and returns the resulting byte-buffer object to Java-level code should ensure that the buffer refers to a valid region of memory that is accessible for reading and, if appropriate, writing. An attempt to access an invalid memory location from Java code will either return an arbitrary value, have no visible effect, or cause an unspecified exception to be thrown.
- Parameters:
address
- the starting address of the memory region (must not beNULL
)capacity
- the size in bytes of the memory region (must be positive)- Returns:
- a local reference to the newly-instantiated
java.nio.ByteBuffer
object. ReturnsNULL
if an exception occurs, or if JNI access to direct buffers is not supported by this virtual machine.
-
GetDirectBufferAddress
public static long GetDirectBufferAddress(java.nio.Buffer buf)
Fetches and returns the starting address of the memory region referenced by the given directjava.nio.Buffer
.This function allows native code to access the same memory region that is accessible to Java code via the buffer object.
- Parameters:
buf
- a directjava.nio.Buffer
object (must not beNULL
)- Returns:
- the starting address of the memory region referenced by the buffer. Returns
NULL
if the memory region is undefined, if the given object is not a directjava.nio.Buffer
, or if JNI access to direct buffers is not supported by this virtual machine.
-
GetObjectRefType
public static int GetObjectRefType(java.lang.Object obj)
Returns the type of the object referred to by theobj
argument. The argumentobj
can either be a local, global or weak global reference.- Parameters:
obj
- a local, global or weak global reference
-
-