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.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | JNI_ABORT
Used in |
| public static final int | JNI_COMMIT
Used in |
| public static final int | JNI_EDETACHED
Possible return values for JNI functions. |
| public static final int | JNI_EEXIST
Possible return values for JNI functions. |
| public static final int | JNI_EINVAL
Possible return values for JNI functions. |
| public static final int | JNI_ENOMEM
Possible return values for JNI functions. |
| public static final int | JNI_ERR
Possible return values for JNI functions. |
| public static final int | JNI_EVERSION
Possible return values for JNI functions. |
| public static final int | JNI_FALSE
jboolean constants. |
| public static final int | JNI_OK
Possible return values for JNI functions. |
| public static final int | JNI_TRUE
jboolean constants. |
| public static final int | JNI_VERSION_10
JNI versions. |
| public static final int | JNI_VERSION_19
JNI versions. |
| public static final int | JNI_VERSION_1_1
JNI versions. |
| public static final int | JNI_VERSION_1_2
JNI versions. |
| public static final int | JNI_VERSION_1_4
JNI versions. |
| public static final int | JNI_VERSION_1_6
JNI versions. |
| public static final int | JNI_VERSION_1_8
JNI versions. |
| public static final int | JNI_VERSION_20
JNI versions. |
| public static final int | JNI_VERSION_21
JNI versions. |
| public static final int | JNI_VERSION_9
JNI versions. |
| public static final int | JNIGlobalRefType
|
| public static final int | JNIInvalidRefType
|
| public static final int | JNILocalRefType
|
| public static final int | JNIWeakGlobalRefType
|
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static void | DeleteGlobalRef(long
a global reference globalRef)Deletes the global reference pointed to by |
| public static void | DeleteWeakGlobalRef(long weakGlobalRef)
Delete the VM resources needed for the given weak global reference. |
| public static native long | |
| public static native long | |
| public static ByteBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetBooleanArrayRegion(byte[]
a Java array array, int the starting index start, ByteBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static ByteBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetByteArrayRegion(byte[]
a Java array array, int the starting index start, ByteBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static ShortBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetCharArrayRegion(char[]
a Java array array, int the starting index start, ShortBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static native long | Returns: the starting address of the memory region referenced by the buffer. ReturnsNULL if the memory region is undefined, if the given object is not a
direct java.nio.Buffer, or if JNI access to direct buffers is not supported by this virtual machine.a direct buf)java.nio.Buffer object (must not be NULL)Fetches and returns the starting address of the memory region referenced by the given direct |
| public static DoubleBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetDoubleArrayRegion(double[]
a Java array array, int the starting index start, DoubleBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static FloatBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetFloatArrayRegion(float[]
a Java array array, int the starting index start, FloatBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static IntBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetIntArrayRegion(int[]
a Java array array, int the starting index start, IntBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static int | GetJavaVM(PointerBuffer
a pointer to where the result should be placed vm)Returns the Java VM interface (used in the Invocation API) associated with the current thread. |
| public static LongBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetLongArrayRegion(long[]
a Java array array, int the starting index start, LongBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static native int | GetObjectRefType(Object
a local, global or weak global reference obj)Returns the type of the object referred to by the |
| public static ShortBuffer | Returns: a pointer to the array elements, orNULL if the operation failsthe primitive array array, ByteBuffer a pointer to a boolean isCopy)Returns the body of the primitive array. |
| public static void | GetShortArrayRegion(short[]
a Java array array, int the starting index start, ShortBuffer the destination buffer buf)Copies a region of a primitive array into a buffer. |
| public static void | GetStringRegion(String str, int start, ByteBuffer buf)
Copies |
| public static void | GetStringUTFRegion(String str, int start, int len, ByteBuffer buf)
Translates |
| public static native int | Returns: the major version number in the higher 16 bits and the minor version number in the lower 16 bitsReturns the version of the native method interface. |
| public static native void | |
| public static native void | |
| public static ByteBuffer | Returns: a local reference to the newly-instantiatedjava.nio.ByteBuffer object. Returns NULL if an exception occurs, or if JNI access to direct
buffers is not supported by this virtual machine.the starting address of the memory region (must not be address, long NULL)the size in bytes of the memory region (must be positive) capacity)Allocates and returns a direct |
| public static native long | Returns: a global reference, orNULL if the system runs out of memorya global or local reference obj)Creates a new global reference to the object referred to by the |
| public static native long | |
| public static native long | |
| public static native void | nGetBooleanArrayRegion(byte[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native long | |
| public static native void | nGetByteArrayRegion(byte[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native long | |
| public static native void | nGetCharArrayRegion(char[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native long | |
| public static native void | nGetDoubleArrayRegion(double[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native long | |
| public static native void | nGetFloatArrayRegion(float[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native long | |
| public static native void | nGetIntArrayRegion(int[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native int | |
| public static native long | |
| public static native void | nGetLongArrayRegion(long[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native long | |
| public static native void | nGetShortArrayRegion(short[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | |
| public static native void | |
| public static native ByteBuffer | |
| public static native void | |
| public static native int | nRegisterNatives(Class<?> targetClass, long methods, int
the number of native methods in the class nMethods)Unsafe version of: |
| public static native void | nReleaseBooleanArrayElements(byte[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nReleaseByteArrayElements(byte[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nReleaseCharArrayElements(char[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nReleaseDoubleArrayElements(double[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nReleaseFloatArrayElements(float[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nReleaseIntArrayElements(int[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nReleaseLongArrayElements(long[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nReleaseShortArrayElements(short[] array, long elems, int mode)
Unsafe version of: |
| public static native void | nSetBooleanArrayRegion(byte[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | nSetByteArrayRegion(byte[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | nSetCharArrayRegion(char[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | nSetDoubleArrayRegion(double[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | nSetFloatArrayRegion(float[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | nSetIntArrayRegion(int[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | nSetLongArrayRegion(long[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native void | nSetShortArrayRegion(short[] array, int start, int
the number of elements to be copied len, long buf)Unsafe version of: |
| public static native Field | |
| public static native Method | nToReflectedMethod(Class<?> cls, long methodID, boolean isStatic)
Unsafe version of: |
| public static int | Returns: “0” on success; returns a negative value on failurethe native methods in the class methodsRegisters native methods with the class specified by the |
| public static void | ReleaseBooleanArrayElements(byte[]
a Java array object array, ByteBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | ReleaseByteArrayElements(byte[]
a Java array object array, ByteBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | ReleaseCharArrayElements(char[]
a Java array object array, ShortBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | ReleaseDoubleArrayElements(double[]
a Java array object array, DoubleBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | ReleaseFloatArrayElements(float[]
a Java array object array, FloatBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | ReleaseIntArrayElements(int[]
a Java array object array, IntBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | ReleaseLongArrayElements(long[]
a Java array object array, LongBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | ReleaseShortArrayElements(short[]
a Java array object array, ShortBuffer a pointer to array elements elems, int mode)Informs the VM that the native code no longer needs access to |
| public static void | SetBooleanArrayRegion(byte[]
a Java array array, int the starting index start, ByteBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static void | SetByteArrayRegion(byte[]
a Java array array, int the starting index start, ByteBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static void | SetCharArrayRegion(char[]
a Java array array, int the starting index start, ShortBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static void | SetDoubleArrayRegion(double[]
a Java array array, int the starting index start, DoubleBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static void | SetFloatArrayRegion(float[]
a Java array array, int the starting index start, FloatBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static void | SetIntArrayRegion(int[]
a Java array array, int the starting index start, IntBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static void | SetLongArrayRegion(long[]
a Java array array, int the starting index start, LongBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static void | SetShortArrayRegion(short[]
a Java array array, int the starting index start, ShortBuffer the source buffer buf)Copies back a region of a primitive array from a buffer. |
| public static Field | ToReflectedField(Class<?> cls, long fieldID, boolean isStatic)
Converts a field ID derived from |
| public static Method | ToReflectedMethod(Class<?> cls, long methodID, boolean
must be set to isStatic)TRUE if the method ID refers to a static field, and # FALSE otherwiseConverts a method ID derived from |
| public static native int | Returns: “0” on success; returns a negative value on failurea Java class object targetClass)Unregisters native methods of a class. |