Class JNINativeInterface
- java.lang.Object
-
- org.lwjgl.system.jni.JNINativeInterface
-
public class JNINativeInterface extends java.lang.ObjectBindings 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 Description static intJNI_ABORT
JNI_COMMITUsed inReleaseScalarArrayElements.static intJNI_EDETACHED
JNI_EEXIST
JNI_EINVAL
JNI_ENOMEM
JNI_ERR
JNI_EVERSIONPossible return values for JNI functions.static intJNI_FALSEjboolean constants.static intJNI_OKPossible return values for JNI functions.static intJNI_TRUEjboolean constants.static intJNI_VERSION_1_1
JNI_VERSION_1_2
JNI_VERSION_1_4
JNI_VERSION_1_6
JNI_VERSION_1_8
JNI_VERSION_10
JNI_VERSION_9JNI versions.static intJNIGlobalRefType
JNIInvalidRefType
JNILocalRefType
JNIWeakGlobalRefTypejobjectRefType: Return values fromGetObjectRefType(java.lang.Object).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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(java.lang.reflect.Field field)Converts aFieldto a field ID.static longFromReflectedMethod(java.lang.reflect.Method method)Converts aMethodorConstructorobject to a method ID.static java.nio.ByteBufferGetBooleanArrayElements(byte[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)Copies a region of a primitive array into a buffer.static java.nio.ByteBufferGetByteArrayElements(byte[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)Copies a region of a primitive array into a buffer.static java.nio.ShortBufferGetCharArrayElements(char[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)Copies a region of a primitive array into a buffer.static longGetDirectBufferAddress(java.nio.Buffer buf)Fetches and returns the starting address of the memory region referenced by the given directjava.nio.Buffer.static java.nio.DoubleBufferGetDoubleArrayElements(double[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)Copies a region of a primitive array into a buffer.static java.nio.FloatBufferGetFloatArrayElements(float[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)Copies a region of a primitive array into a buffer.static java.nio.IntBufferGetIntArrayElements(int[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)Copies a region of a primitive array into a buffer.static intGetJavaVM(PointerBuffer vm)Returns the Java VM interface (used in the Invocation API) associated with the current thread.static java.nio.LongBufferGetLongArrayElements(long[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)Copies a region of a primitive array into a buffer.static intGetObjectRefType(java.lang.Object obj)Returns the type of the object referred to by theobjargument.static java.nio.ShortBufferGetShortArrayElements(short[] array, java.nio.ByteBuffer isCopy)Returns the body of the primitive array.static voidGetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)Copies a region of a primitive array into a buffer.static voidGetStringRegion(java.lang.String str, int start, java.nio.ByteBuffer buf)Copieslennumber of Unicode characters beginning at offsetstartto the given bufferbuf.static voidGetStringUTFRegion(java.lang.String str, int start, int len, java.nio.ByteBuffer buf)Translateslennumber of Unicode characters beginning at offset start into modified UTF-8 encoding and place the result in the given bufferbuf.static intGetVersion()Returns 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 java.nio.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(java.lang.Object obj)Creates a new global reference to the object referred to by theobjargument.static longNewWeakGlobalRef(java.lang.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(java.lang.String str, int start, int len, long buf)Unsafe version of:GetStringRegion(java.lang.String, int, java.nio.ByteBuffer)static voidnGetStringUTFRegion(java.lang.String str, int start, int len, long buf)Unsafe version of:GetStringUTFRegion(java.lang.String, int, int, java.nio.ByteBuffer)static java.nio.ByteBuffernNewDirectByteBuffer(long address, long capacity)Unsafe version of:NewDirectByteBuffer(long, long)static intnRegisterNatives(java.lang.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 java.lang.reflect.FieldnToReflectedField(java.lang.Class<?> cls, long fieldID, boolean isStatic)Unsafe version of:ToReflectedField(java.lang.Class<?>, long, boolean)static java.lang.reflect.MethodnToReflectedMethod(java.lang.Class<?> cls, long methodID, boolean isStatic)Unsafe version of:ToReflectedMethod(java.lang.Class<?>, long, boolean)static intRegisterNatives(java.lang.Class<?> targetClass, JNINativeMethod.Buffer methods)Registers native methods with the class specified by thetargetClassargument.static voidReleaseBooleanArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidReleaseByteArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidReleaseCharArrayElements(char[] array, java.nio.ShortBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidReleaseDoubleArrayElements(double[] array, java.nio.DoubleBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidReleaseFloatArrayElements(float[] array, java.nio.FloatBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidReleaseIntArrayElements(int[] array, java.nio.IntBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidReleaseLongArrayElements(long[] array, java.nio.LongBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidReleaseShortArrayElements(short[] array, java.nio.ShortBuffer elems, int mode)Informs the VM that the native code no longer needs access toelems.static voidSetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)Copies back a region of a primitive array from a buffer.static voidSetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)Copies back a region of a primitive array from a buffer.static voidSetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)Copies back a region of a primitive array from a buffer.static voidSetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)Copies back a region of a primitive array from a buffer.static voidSetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)Copies back a region of a primitive array from a buffer.static voidSetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)Copies back a region of a primitive array from a buffer.static voidSetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)Copies back a region of a primitive array from a buffer.static voidSetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)Copies back a region of a primitive array from a buffer.static java.lang.reflect.FieldToReflectedField(java.lang.Class<?> cls, long fieldID, boolean isStatic)Converts a field ID derived fromclsto aFieldobject.static java.lang.reflect.MethodToReflectedMethod(java.lang.Class<?> cls, long methodID, boolean isStatic)Converts a method ID derived fromclsto aMethodorConstructorobject.static intUnregisterNatives(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_VERSION_10
JNI versions.
-
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 aMethodorConstructorobject to a method ID.
-
FromReflectedField
public static long FromReflectedField(java.lang.reflect.Field field)
Converts aFieldto a field ID.
-
nToReflectedMethod
@Nullable public static java.lang.reflect.Method nToReflectedMethod(java.lang.Class<?> cls, long methodID, boolean isStatic)Unsafe version of:ToReflectedMethod(java.lang.Class<?>, long, boolean)
-
ToReflectedMethod
@Nullable public static java.lang.reflect.Method ToReflectedMethod(java.lang.Class<?> cls, long methodID, boolean isStatic)Converts a method ID derived fromclsto aMethodorConstructorobject.- Parameters:
isStatic- must be set toTRUEif the method ID refers to a static field, and # FALSE otherwise
-
nToReflectedField
@Nullable public static java.lang.reflect.Field nToReflectedField(java.lang.Class<?> cls, long fieldID, boolean isStatic)Unsafe version of:ToReflectedField(java.lang.Class<?>, long, boolean)
-
ToReflectedField
@Nullable public static java.lang.reflect.Field ToReflectedField(java.lang.Class<?> cls, long fieldID, boolean isStatic)Converts a field ID derived fromclsto aFieldobject.
-
NewGlobalRef
public static long NewGlobalRef(java.lang.Object obj)
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
@Nullable public static java.nio.ByteBuffer GetBooleanArrayElements(byte[] array, @Nullable java.nio.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
public static void ReleaseBooleanArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)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
@Nullable public static java.nio.ByteBuffer GetByteArrayElements(byte[] array, @Nullable java.nio.ByteBuffer isCopy)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
public static void ReleaseByteArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)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
@Nullable public static java.nio.ShortBuffer GetCharArrayElements(char[] array, @Nullable java.nio.ByteBuffer isCopy)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
public static void ReleaseCharArrayElements(char[] array, java.nio.ShortBuffer elems, int mode)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
@Nullable public static java.nio.ShortBuffer GetShortArrayElements(short[] array, @Nullable java.nio.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
public static void ReleaseShortArrayElements(short[] array, java.nio.ShortBuffer elems, int mode)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
@Nullable public static java.nio.IntBuffer GetIntArrayElements(int[] array, @Nullable java.nio.ByteBuffer isCopy)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
public static void ReleaseIntArrayElements(int[] array, java.nio.IntBuffer elems, int mode)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
@Nullable public static java.nio.LongBuffer GetLongArrayElements(long[] array, @Nullable java.nio.ByteBuffer isCopy)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
public static void ReleaseLongArrayElements(long[] array, java.nio.LongBuffer elems, int mode)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
@Nullable public static java.nio.FloatBuffer GetFloatArrayElements(float[] array, @Nullable java.nio.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
public static void ReleaseFloatArrayElements(float[] array, java.nio.FloatBuffer elems, int mode)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
@Nullable public static java.nio.DoubleBuffer GetDoubleArrayElements(double[] array, @Nullable java.nio.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
public static void ReleaseDoubleArrayElements(double[] array, java.nio.DoubleBuffer elems, int mode)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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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
-
nRegisterNatives
public static int nRegisterNatives(java.lang.Class<?> targetClass, long methods, int nMethods)- Parameters:
nMethods- the number of native methods in the class
-
RegisterNatives
public static int RegisterNatives(java.lang.Class<?> targetClass, JNINativeMethod.Buffer methods)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
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
-
nGetJavaVM
public static int nGetJavaVM(long vm)
Unsafe version of:GetJavaVM(org.lwjgl.PointerBuffer)
-
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
-
nGetStringRegion
public static void nGetStringRegion(java.lang.String str, int start, int len, long buf)Unsafe version of:GetStringRegion(java.lang.String, int, java.nio.ByteBuffer)
-
GetStringRegion
public static void GetStringRegion(java.lang.String str, int start, java.nio.ByteBuffer buf)Copieslennumber of Unicode characters beginning at offsetstartto the given bufferbuf.
-
nGetStringUTFRegion
public static void nGetStringUTFRegion(java.lang.String str, int start, int len, long buf)Unsafe version of:GetStringUTFRegion(java.lang.String, int, int, java.nio.ByteBuffer)
-
GetStringUTFRegion
public static void GetStringUTFRegion(java.lang.String str, int start, int len, java.nio.ByteBuffer buf)Translateslennumber of Unicode characters beginning at offset start into modified UTF-8 encoding and place the result in the given bufferbuf.
-
NewWeakGlobalRef
public static long NewWeakGlobalRef(java.lang.Object obj)
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
@Nullable public static java.nio.ByteBuffer nNewDirectByteBuffer(long address, long capacity)Unsafe version of:NewDirectByteBuffer(long, long)
-
NewDirectByteBuffer
@Nullable public static java.nio.ByteBuffer NewDirectByteBuffer(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.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
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.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
public static int GetObjectRefType(java.lang.Object obj)
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
-
-