Class JNINativeInterface
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
FieldsModifier and TypeFieldDescriptionstatic final intUsed inReleaseScalarArrayElements.static final intUsed inReleaseScalarArrayElements.static final intPossible return values for JNI functions.static final intPossible return values for JNI functions.static final intPossible return values for JNI functions.static final intPossible return values for JNI functions.static final intPossible return values for JNI functions.static final intPossible return values for JNI functions.static final intjboolean constants.static final intPossible return values for JNI functions.static final intjboolean constants.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intJNI versions.static final intjobjectRefType: Return values fromGetObjectRefType(java.lang.Object).static final intjobjectRefType: Return values fromGetObjectRefType(java.lang.Object).static final intjobjectRefType: Return values fromGetObjectRefType(java.lang.Object).static final intjobjectRefType: Return values fromGetObjectRefType(java.lang.Object). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDeleteGlobalRef(long globalRef) Deletes the global reference pointed to byglobalRef.static voidDeleteWeakGlobalRef(long weakGlobalRef) Delete the VM resources needed for the given weak global reference.static longFromReflectedField(Field field) Converts aFieldto a field ID.static longFromReflectedMethod(Method method) Converts aMethodorConstructorobject to a method ID.static @Nullable ByteBufferGetBooleanArrayElements(byte[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetBooleanArrayRegion(byte[] array, int start, ByteBuffer buf) Copies a region of a primitive array into a buffer.static @Nullable ByteBufferGetByteArrayElements(byte[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetByteArrayRegion(byte[] array, int start, ByteBuffer buf) Copies a region of a primitive array into a buffer.static @Nullable ShortBufferGetCharArrayElements(char[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetCharArrayRegion(char[] array, int start, ShortBuffer buf) Copies a region of a primitive array into a buffer.static longFetches and returns the starting address of the memory region referenced by the given directjava.nio.Buffer.static @Nullable DoubleBufferGetDoubleArrayElements(double[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetDoubleArrayRegion(double[] array, int start, DoubleBuffer buf) Copies a region of a primitive array into a buffer.static @Nullable FloatBufferGetFloatArrayElements(float[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetFloatArrayRegion(float[] array, int start, FloatBuffer buf) Copies a region of a primitive array into a buffer.static @Nullable IntBufferGetIntArrayElements(int[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetIntArrayRegion(int[] array, int start, IntBuffer buf) Copies a region of a primitive array into a buffer.static intGetJavaVM(org.lwjgl.PointerBuffer vm) Returns the Java VM interface (used in the Invocation API) associated with the current thread.static @Nullable LongBufferGetLongArrayElements(long[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetLongArrayRegion(long[] array, int start, LongBuffer buf) Copies a region of a primitive array into a buffer.static intGetObjectRefType(Object obj) Returns the type of the object referred to by theobjargument.static @Nullable ShortBufferGetShortArrayElements(short[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array.static voidGetShortArrayRegion(short[] array, int start, ShortBuffer buf) Copies a region of a primitive array into a buffer.static voidGetStringRegion(String str, int start, ByteBuffer buf) Copieslennumber of Unicode characters beginning at offsetstartto the given bufferbuf.static voidGetStringUTFRegion(String str, int start, int len, ByteBuffer buf) Translateslennumber of Unicode characters beginning at offset start into modified UTF-8 encoding and place the result in the given bufferbuf.static intReturns the version of the native method interface.static voidnDeleteGlobalRef(long globalRef) Unsafe version of:DeleteGlobalRef(long)static voidnDeleteWeakGlobalRef(long weakGlobalRef) Unsafe version of:DeleteWeakGlobalRef(long)static @Nullable ByteBufferNewDirectByteBuffer(long address, long capacity) Allocates and returns a directjava.nio.ByteBufferreferring to the block of memory starting at the memory address address and extending capacity bytes.static longNewGlobalRef(Object obj) Creates a new global reference to the object referred to by theobjargument.static longNewWeakGlobalRef(Object obj) Creates a new weak global reference.static longnGetBooleanArrayElements(byte[] array, long isCopy) Unsafe version of:GetBooleanArrayElements(byte[], java.nio.ByteBuffer)static voidnGetBooleanArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:GetBooleanArrayRegion(byte[], int, java.nio.ByteBuffer)static longnGetByteArrayElements(byte[] array, long isCopy) Unsafe version of:GetByteArrayElements(byte[], java.nio.ByteBuffer)static voidnGetByteArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:GetByteArrayRegion(byte[], int, java.nio.ByteBuffer)static longnGetCharArrayElements(char[] array, long isCopy) Unsafe version of:GetCharArrayElements(char[], java.nio.ByteBuffer)static voidnGetCharArrayRegion(char[] array, int start, int len, long buf) Unsafe version of:GetCharArrayRegion(char[], int, java.nio.ShortBuffer)static longnGetDoubleArrayElements(double[] array, long isCopy) Unsafe version of:GetDoubleArrayElements(double[], java.nio.ByteBuffer)static voidnGetDoubleArrayRegion(double[] array, int start, int len, long buf) Unsafe version of:GetDoubleArrayRegion(double[], int, java.nio.DoubleBuffer)static longnGetFloatArrayElements(float[] array, long isCopy) Unsafe version of:GetFloatArrayElements(float[], java.nio.ByteBuffer)static voidnGetFloatArrayRegion(float[] array, int start, int len, long buf) Unsafe version of:GetFloatArrayRegion(float[], int, java.nio.FloatBuffer)static longnGetIntArrayElements(int[] array, long isCopy) Unsafe version of:GetIntArrayElements(int[], java.nio.ByteBuffer)static voidnGetIntArrayRegion(int[] array, int start, int len, long buf) Unsafe version of:GetIntArrayRegion(int[], int, java.nio.IntBuffer)static intnGetJavaVM(long vm) Unsafe version of:GetJavaVM(org.lwjgl.PointerBuffer)static longnGetLongArrayElements(long[] array, long isCopy) Unsafe version of:GetLongArrayElements(long[], java.nio.ByteBuffer)static voidnGetLongArrayRegion(long[] array, int start, int len, long buf) Unsafe version of:GetLongArrayRegion(long[], int, java.nio.LongBuffer)static longnGetShortArrayElements(short[] array, long isCopy) Unsafe version of:GetShortArrayElements(short[], java.nio.ByteBuffer)static voidnGetShortArrayRegion(short[] array, int start, int len, long buf) Unsafe version of:GetShortArrayRegion(short[], int, java.nio.ShortBuffer)static voidnGetStringRegion(String str, int start, int len, long buf) Unsafe version of:GetStringRegion(java.lang.String, int, java.nio.ByteBuffer)static voidnGetStringUTFRegion(String str, int start, int len, long buf) Unsafe version of:GetStringUTFRegion(java.lang.String, int, int, java.nio.ByteBuffer)static @Nullable ByteBuffernNewDirectByteBuffer(long address, long capacity) Unsafe version of:NewDirectByteBuffer(long, long)static voidnoop()No-op JNI function for benchmarking.static intnRegisterNatives(Class<?> targetClass, long methods, int nMethods) static voidnReleaseBooleanArrayElements(byte[] array, long elems, int mode) Unsafe version of:ReleaseBooleanArrayElements(byte[], java.nio.ByteBuffer, int)static voidnReleaseByteArrayElements(byte[] array, long elems, int mode) Unsafe version of:ReleaseByteArrayElements(byte[], java.nio.ByteBuffer, int)static voidnReleaseCharArrayElements(char[] array, long elems, int mode) Unsafe version of:ReleaseCharArrayElements(char[], java.nio.ShortBuffer, int)static voidnReleaseDoubleArrayElements(double[] array, long elems, int mode) Unsafe version of:ReleaseDoubleArrayElements(double[], java.nio.DoubleBuffer, int)static voidnReleaseFloatArrayElements(float[] array, long elems, int mode) Unsafe version of:ReleaseFloatArrayElements(float[], java.nio.FloatBuffer, int)static voidnReleaseIntArrayElements(int[] array, long elems, int mode) Unsafe version of:ReleaseIntArrayElements(int[], java.nio.IntBuffer, int)static voidnReleaseLongArrayElements(long[] array, long elems, int mode) Unsafe version of:ReleaseLongArrayElements(long[], java.nio.LongBuffer, int)static voidnReleaseShortArrayElements(short[] array, long elems, int mode) Unsafe version of:ReleaseShortArrayElements(short[], java.nio.ShortBuffer, int)static voidnSetBooleanArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:SetBooleanArrayRegion(byte[], int, java.nio.ByteBuffer)static voidnSetByteArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:SetByteArrayRegion(byte[], int, java.nio.ByteBuffer)static voidnSetCharArrayRegion(char[] array, int start, int len, long buf) Unsafe version of:SetCharArrayRegion(char[], int, java.nio.ShortBuffer)static voidnSetDoubleArrayRegion(double[] array, int start, int len, long buf) Unsafe version of:SetDoubleArrayRegion(double[], int, java.nio.DoubleBuffer)static voidnSetFloatArrayRegion(float[] array, int start, int len, long buf) Unsafe version of:SetFloatArrayRegion(float[], int, java.nio.FloatBuffer)static voidnSetIntArrayRegion(int[] array, int start, int len, long buf) Unsafe version of:SetIntArrayRegion(int[], int, java.nio.IntBuffer)static voidnSetLongArrayRegion(long[] array, int start, int len, long buf) Unsafe version of:SetLongArrayRegion(long[], int, java.nio.LongBuffer)static voidnSetShortArrayRegion(short[] array, int start, int len, long buf) Unsafe version of:SetShortArrayRegion(short[], int, java.nio.ShortBuffer)static @Nullable FieldnToReflectedField(Class<?> cls, long fieldID, boolean isStatic) Unsafe version of:ToReflectedField(java.lang.Class<?>, long, boolean)static @Nullable MethodnToReflectedMethod(Class<?> cls, long methodID, boolean isStatic) Unsafe version of:ToReflectedMethod(java.lang.Class<?>, long, boolean)static intRegisterNatives(Class<?> targetClass, JNINativeMethod.Buffer methods) Registers native methods with the class specified by thetargetClassargument.static voidReleaseBooleanArrayElements(byte[] array, ByteBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidReleaseByteArrayElements(byte[] array, ByteBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidReleaseCharArrayElements(char[] array, ShortBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidReleaseDoubleArrayElements(double[] array, DoubleBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidReleaseFloatArrayElements(float[] array, FloatBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidReleaseIntArrayElements(int[] array, IntBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidReleaseLongArrayElements(long[] array, LongBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidReleaseShortArrayElements(short[] array, ShortBuffer elems, int mode) Informs the VM that the native code no longer needs access toelems.static voidSetBooleanArrayRegion(byte[] array, int start, ByteBuffer buf) Copies back a region of a primitive array from a buffer.static voidSetByteArrayRegion(byte[] array, int start, ByteBuffer buf) Copies back a region of a primitive array from a buffer.static voidSetCharArrayRegion(char[] array, int start, ShortBuffer buf) Copies back a region of a primitive array from a buffer.static voidSetDoubleArrayRegion(double[] array, int start, DoubleBuffer buf) Copies back a region of a primitive array from a buffer.static voidSetFloatArrayRegion(float[] array, int start, FloatBuffer buf) Copies back a region of a primitive array from a buffer.static voidSetIntArrayRegion(int[] array, int start, IntBuffer buf) Copies back a region of a primitive array from a buffer.static voidSetLongArrayRegion(long[] array, int start, LongBuffer buf) Copies back a region of a primitive array from a buffer.static voidSetShortArrayRegion(short[] array, int start, ShortBuffer buf) Copies back a region of a primitive array from a buffer.static @Nullable FieldToReflectedField(Class<?> cls, long fieldID, boolean isStatic) Converts a field ID derived fromclsto aFieldobject.static @Nullable MethodToReflectedMethod(Class<?> cls, long methodID, boolean isStatic) static intUnregisterNatives(Class<?> targetClass) Unregisters native methods of a class.
-
Field Details
-
JNI_VERSION_1_1
public static final int JNI_VERSION_1_1JNI versions.- See Also:
-
JNI_VERSION_1_2
public static final int JNI_VERSION_1_2JNI versions.- See Also:
-
JNI_VERSION_1_4
public static final int JNI_VERSION_1_4JNI versions.- See Also:
-
JNI_VERSION_1_6
public static final int JNI_VERSION_1_6JNI versions.- See Also:
-
JNI_VERSION_1_8
public static final int JNI_VERSION_1_8JNI versions.- See Also:
-
JNI_VERSION_9
public static final int JNI_VERSION_9JNI versions.- See Also:
-
JNI_VERSION_10
public static final int JNI_VERSION_10JNI versions.- See Also:
-
JNI_VERSION_19
public static final int JNI_VERSION_19JNI versions.- See Also:
-
JNI_VERSION_20
public static final int JNI_VERSION_20JNI versions.- See Also:
-
JNI_VERSION_21
public static final int JNI_VERSION_21JNI versions.- See Also:
-
JNI_VERSION_24
public static final int JNI_VERSION_24JNI versions.- See Also:
-
JNIInvalidRefType
public static final int JNIInvalidRefType- See Also:
-
JNILocalRefType
public static final int JNILocalRefType- See Also:
-
JNIGlobalRefType
public static final int JNIGlobalRefType- See Also:
-
JNIWeakGlobalRefType
public static final int JNIWeakGlobalRefType- See Also:
-
JNI_FALSE
public static final int JNI_FALSEjboolean constants.- See Also:
-
JNI_TRUE
public static final int JNI_TRUEjboolean constants.- See Also:
-
JNI_OK
public static final int JNI_OKPossible return values for JNI functions.Enum values:
- See Also:
-
JNI_ERR
public static final int JNI_ERRPossible return values for JNI functions.Enum values:
- See Also:
-
JNI_EDETACHED
public static final int JNI_EDETACHEDPossible return values for JNI functions.Enum values:
- See Also:
-
JNI_EVERSION
public static final int JNI_EVERSIONPossible return values for JNI functions.Enum values:
- See Also:
-
JNI_ENOMEM
public static final int JNI_ENOMEMPossible return values for JNI functions.Enum values:
- See Also:
-
JNI_EEXIST
public static final int JNI_EEXISTPossible return values for JNI functions.Enum values:
- See Also:
-
JNI_EINVAL
public static final int JNI_EINVALPossible return values for JNI functions.Enum values:
- See Also:
-
JNI_COMMIT
public static final int JNI_COMMITUsed inReleaseScalarArrayElements.- See Also:
-
JNI_ABORT
public static final int JNI_ABORTUsed inReleaseScalarArrayElements.- See Also:
-
-
Method Details
-
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
Converts aMethodorConstructorobject to a method ID. -
FromReflectedField
Converts aFieldto a field ID. -
nToReflectedMethod
Unsafe version of:ToReflectedMethod(java.lang.Class<?>, long, boolean) -
ToReflectedMethod
- Parameters:
isStatic- must be set toTRUEif the method ID refers to a static field, and # FALSE otherwise
-
nToReflectedField
Unsafe version of:ToReflectedField(java.lang.Class<?>, long, boolean) -
ToReflectedField
Converts a field ID derived fromclsto aFieldobject. -
NewGlobalRef
Creates a new global reference to the object referred to by theobjargument. Theobjargument may be a global or local reference. Global references must be explicitly disposed of by callingDeleteGlobalRef(long).- Parameters:
obj- a global or local reference- Returns:
- a global reference, or
NULLif the system runs out of memory
-
nDeleteGlobalRef
public static void nDeleteGlobalRef(long globalRef) Unsafe version of:DeleteGlobalRef(long) -
DeleteGlobalRef
public static void DeleteGlobalRef(long globalRef) Deletes the global reference pointed to byglobalRef.- Parameters:
globalRef- a global reference
-
nGetBooleanArrayElements
public static long nGetBooleanArrayElements(byte[] array, long isCopy) Unsafe version of:GetBooleanArrayElements(byte[], java.nio.ByteBuffer) -
GetBooleanArrayElements
public static @Nullable ByteBuffer GetBooleanArrayElements(byte[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array. The result is valid until theReleaseBooleanArrayElements(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 untilReleaseBooleanArrayElements(byte[], java.nio.ByteBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseBooleanArrayElements
public static void nReleaseBooleanArrayElements(byte[] array, long elems, int mode) Unsafe version of:ReleaseBooleanArrayElements(byte[], java.nio.ByteBuffer, int) -
ReleaseBooleanArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetBooleanArrayElements(byte[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetByteArrayElements
public static long nGetByteArrayElements(byte[] array, long isCopy) Unsafe version of:GetByteArrayElements(byte[], java.nio.ByteBuffer) -
GetByteArrayElements
Returns the body of the primitive array. The result is valid until theReleaseByteArrayElements(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 untilReleaseByteArrayElements(byte[], java.nio.ByteBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseByteArrayElements
public static void nReleaseByteArrayElements(byte[] array, long elems, int mode) Unsafe version of:ReleaseByteArrayElements(byte[], java.nio.ByteBuffer, int) -
ReleaseByteArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetByteArrayElements(byte[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetCharArrayElements
public static long nGetCharArrayElements(char[] array, long isCopy) Unsafe version of:GetCharArrayElements(char[], java.nio.ByteBuffer) -
GetCharArrayElements
Returns the body of the primitive array. The result is valid until theReleaseCharArrayElements(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 untilReleaseCharArrayElements(char[], java.nio.ShortBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseCharArrayElements
public static void nReleaseCharArrayElements(char[] array, long elems, int mode) Unsafe version of:ReleaseCharArrayElements(char[], java.nio.ShortBuffer, int) -
ReleaseCharArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetCharArrayElements(char[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetShortArrayElements
public static long nGetShortArrayElements(short[] array, long isCopy) Unsafe version of:GetShortArrayElements(short[], java.nio.ByteBuffer) -
GetShortArrayElements
public static @Nullable ShortBuffer GetShortArrayElements(short[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array. The result is valid until theReleaseShortArrayElements(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 untilReleaseShortArrayElements(short[], java.nio.ShortBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseShortArrayElements
public static void nReleaseShortArrayElements(short[] array, long elems, int mode) Unsafe version of:ReleaseShortArrayElements(short[], java.nio.ShortBuffer, int) -
ReleaseShortArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetShortArrayElements(short[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetIntArrayElements
public static long nGetIntArrayElements(int[] array, long isCopy) Unsafe version of:GetIntArrayElements(int[], java.nio.ByteBuffer) -
GetIntArrayElements
Returns the body of the primitive array. The result is valid until theReleaseIntArrayElements(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 untilReleaseIntArrayElements(int[], java.nio.IntBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseIntArrayElements
public static void nReleaseIntArrayElements(int[] array, long elems, int mode) Unsafe version of:ReleaseIntArrayElements(int[], java.nio.IntBuffer, int) -
ReleaseIntArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetIntArrayElements(int[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetLongArrayElements
public static long nGetLongArrayElements(long[] array, long isCopy) Unsafe version of:GetLongArrayElements(long[], java.nio.ByteBuffer) -
GetLongArrayElements
Returns the body of the primitive array. The result is valid until theReleaseLongArrayElements(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 untilReleaseLongArrayElements(long[], java.nio.LongBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseLongArrayElements
public static void nReleaseLongArrayElements(long[] array, long elems, int mode) Unsafe version of:ReleaseLongArrayElements(long[], java.nio.LongBuffer, int) -
ReleaseLongArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetLongArrayElements(long[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetFloatArrayElements
public static long nGetFloatArrayElements(float[] array, long isCopy) Unsafe version of:GetFloatArrayElements(float[], java.nio.ByteBuffer) -
GetFloatArrayElements
public static @Nullable FloatBuffer GetFloatArrayElements(float[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array. The result is valid until theReleaseFloatArrayElements(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 untilReleaseFloatArrayElements(float[], java.nio.FloatBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseFloatArrayElements
public static void nReleaseFloatArrayElements(float[] array, long elems, int mode) Unsafe version of:ReleaseFloatArrayElements(float[], java.nio.FloatBuffer, int) -
ReleaseFloatArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetFloatArrayElements(float[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetDoubleArrayElements
public static long nGetDoubleArrayElements(double[] array, long isCopy) Unsafe version of:GetDoubleArrayElements(double[], java.nio.ByteBuffer) -
GetDoubleArrayElements
public static @Nullable DoubleBuffer GetDoubleArrayElements(double[] array, @Nullable ByteBuffer isCopy) Returns the body of the primitive array. The result is valid until theReleaseDoubleArrayElements(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 untilReleaseDoubleArrayElements(double[], java.nio.DoubleBuffer, int)is called.If
isCopyis notNULL, then*isCopyis set toTRUEif a copy is made; or it is set toFALSEif no copy is made.- Parameters:
array- the primitive arrayisCopy- a pointer to a boolean- Returns:
- a pointer to the array elements, or
NULLif the operation fails
-
nReleaseDoubleArrayElements
public static void nReleaseDoubleArrayElements(double[] array, long elems, int mode) Unsafe version of:ReleaseDoubleArrayElements(double[], java.nio.DoubleBuffer, int) -
ReleaseDoubleArrayElements
Informs the VM that the native code no longer needs access toelems. Theelemsargument is a pointer derived from array using theGetDoubleArrayElements(double[], java.nio.ByteBuffer)function. If necessary, this function copies back all changes made to elems to the original array.The
modeargument provides information on how the array buffer should be released.modehas no effect ifelemsis 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 COMMITcopy back the content but do not free the elems buffer ABORTfree 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.
-
nGetBooleanArrayRegion
public static void nGetBooleanArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:GetBooleanArrayRegion(byte[], int, java.nio.ByteBuffer)- Parameters:
len- the number of elements to be copied
-
GetBooleanArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetBooleanArrayRegion
public static void nSetBooleanArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:SetBooleanArrayRegion(byte[], int, java.nio.ByteBuffer)- Parameters:
len- the number of elements to be copied
-
SetBooleanArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nGetByteArrayRegion
public static void nGetByteArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:GetByteArrayRegion(byte[], int, java.nio.ByteBuffer)- Parameters:
len- the number of elements to be copied
-
GetByteArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetByteArrayRegion
public static void nSetByteArrayRegion(byte[] array, int start, int len, long buf) Unsafe version of:SetByteArrayRegion(byte[], int, java.nio.ByteBuffer)- Parameters:
len- the number of elements to be copied
-
SetByteArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nGetCharArrayRegion
public static void nGetCharArrayRegion(char[] array, int start, int len, long buf) Unsafe version of:GetCharArrayRegion(char[], int, java.nio.ShortBuffer)- Parameters:
len- the number of elements to be copied
-
GetCharArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetCharArrayRegion
public static void nSetCharArrayRegion(char[] array, int start, int len, long buf) Unsafe version of:SetCharArrayRegion(char[], int, java.nio.ShortBuffer)- Parameters:
len- the number of elements to be copied
-
SetCharArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nGetShortArrayRegion
public static void nGetShortArrayRegion(short[] array, int start, int len, long buf) Unsafe version of:GetShortArrayRegion(short[], int, java.nio.ShortBuffer)- Parameters:
len- the number of elements to be copied
-
GetShortArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetShortArrayRegion
public static void nSetShortArrayRegion(short[] array, int start, int len, long buf) Unsafe version of:SetShortArrayRegion(short[], int, java.nio.ShortBuffer)- Parameters:
len- the number of elements to be copied
-
SetShortArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nGetIntArrayRegion
public static void nGetIntArrayRegion(int[] array, int start, int len, long buf) Unsafe version of:GetIntArrayRegion(int[], int, java.nio.IntBuffer)- Parameters:
len- the number of elements to be copied
-
GetIntArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetIntArrayRegion
public static void nSetIntArrayRegion(int[] array, int start, int len, long buf) Unsafe version of:SetIntArrayRegion(int[], int, java.nio.IntBuffer)- Parameters:
len- the number of elements to be copied
-
SetIntArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nGetLongArrayRegion
public static void nGetLongArrayRegion(long[] array, int start, int len, long buf) Unsafe version of:GetLongArrayRegion(long[], int, java.nio.LongBuffer)- Parameters:
len- the number of elements to be copied
-
GetLongArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetLongArrayRegion
public static void nSetLongArrayRegion(long[] array, int start, int len, long buf) Unsafe version of:SetLongArrayRegion(long[], int, java.nio.LongBuffer)- Parameters:
len- the number of elements to be copied
-
SetLongArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nGetFloatArrayRegion
public static void nGetFloatArrayRegion(float[] array, int start, int len, long buf) Unsafe version of:GetFloatArrayRegion(float[], int, java.nio.FloatBuffer)- Parameters:
len- the number of elements to be copied
-
GetFloatArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetFloatArrayRegion
public static void nSetFloatArrayRegion(float[] array, int start, int len, long buf) Unsafe version of:SetFloatArrayRegion(float[], int, java.nio.FloatBuffer)- Parameters:
len- the number of elements to be copied
-
SetFloatArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nGetDoubleArrayRegion
public static void nGetDoubleArrayRegion(double[] array, int start, int len, long buf) Unsafe version of:GetDoubleArrayRegion(double[], int, java.nio.DoubleBuffer)- Parameters:
len- the number of elements to be copied
-
GetDoubleArrayRegion
Copies a region of a primitive array into a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the destination buffer
-
nSetDoubleArrayRegion
public static void nSetDoubleArrayRegion(double[] array, int start, int len, long buf) Unsafe version of:SetDoubleArrayRegion(double[], int, java.nio.DoubleBuffer)- Parameters:
len- the number of elements to be copied
-
SetDoubleArrayRegion
Copies back a region of a primitive array from a buffer.- Parameters:
array- a Java arraystart- the starting indexbuf- the source buffer
-
nRegisterNatives
- Parameters:
nMethods- the number of native methods in the class
-
RegisterNatives
Registers native methods with the class specified by thetargetClassargument. 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 theJNINativeMethodstructure are pointers to modified UTF-8 strings. ThenMethodsparameter specifies the number of native methods in the array.- Parameters:
methods- the native methods in the class- Returns:
- “0” on success; returns a negative value on failure
-
UnregisterNatives
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
-
nGetJavaVM
public static int nGetJavaVM(long vm) Unsafe version of:GetJavaVM(org.lwjgl.PointerBuffer) -
GetJavaVM
public static int GetJavaVM(org.lwjgl.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
-
nGetStringRegion
Unsafe version of:GetStringRegion(java.lang.String, int, java.nio.ByteBuffer) -
GetStringRegion
Copieslennumber of Unicode characters beginning at offsetstartto the given bufferbuf. -
nGetStringUTFRegion
Unsafe version of:GetStringUTFRegion(java.lang.String, int, int, java.nio.ByteBuffer) -
GetStringUTFRegion
Translateslennumber of Unicode characters beginning at offset start into modified UTF-8 encoding and place the result in the given bufferbuf. -
NewWeakGlobalRef
Creates a new weak global reference. ReturnsNULLifobjrefers to null, or if the VM runs out of memory. If the VM runs out of memory, anOutOfMemoryErrorwill be thrown. -
nDeleteWeakGlobalRef
public static void nDeleteWeakGlobalRef(long weakGlobalRef) Unsafe version of:DeleteWeakGlobalRef(long) -
DeleteWeakGlobalRef
public static void DeleteWeakGlobalRef(long weakGlobalRef) Delete the VM resources needed for the given weak global reference. -
nNewDirectByteBuffer
Unsafe version of:NewDirectByteBuffer(long, long) -
NewDirectByteBuffer
Allocates and returns a directjava.nio.ByteBufferreferring 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.ByteBufferobject. ReturnsNULLif an exception occurs, or if JNI access to direct buffers is not supported by this virtual machine.
-
GetDirectBufferAddress
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.Bufferobject (must not beNULL)- Returns:
- the starting address of the memory region referenced by the buffer. Returns
NULLif 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
Returns the type of the object referred to by theobjargument. The argumentobjcan either be a local, global or weak global reference.- Parameters:
obj- a local, global or weak global reference
-
noop
public static void noop()No-op JNI function for benchmarking.
-