Class JNINativeInterface

java.lang.Object
org.lwjgl.system.jni.JNINativeInterface

public class JNINativeInterface extends Object
Bindings to the Java Native Interface (JNI).

The JNI is a native programming interface. It allows Java code that runs inside a Java Virtual Machine (VM) to interoperate with applications and libraries written in other programming languages, such as C, C++, and assembly.

The most important benefit of the JNI is that it imposes no restrictions on the implementation of the underlying Java VM. Therefore, Java VM vendors can add support for the JNI without affecting other parts of the VM. Programmers can write one version of a native application or library and expect it to work with all Java VMs supporting the JNI.

LWJGL: Only functions that can reasonably be called from Java are exposed.

  • Field Details

  • 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

      public static long FromReflectedMethod(Method method)
      Converts a Method or Constructor object to a method ID.
    • FromReflectedField

      public static long FromReflectedField(Field field)
      Converts a Field to a field ID.
    • nToReflectedMethod

      @Nullable public static Method nToReflectedMethod(Class<?> cls, long methodID, boolean isStatic)
    • ToReflectedMethod

      @Nullable public static Method ToReflectedMethod(Class<?> cls, long methodID, boolean isStatic)
      Converts a method ID derived from cls to a Method or Constructor object.
      Parameters:
      isStatic - must be set to TRUE if the method ID refers to a static field, and # FALSE otherwise
    • nToReflectedField

      @Nullable public static Field nToReflectedField(Class<?> cls, long fieldID, boolean isStatic)
    • ToReflectedField

      @Nullable public static Field ToReflectedField(Class<?> cls, long fieldID, boolean isStatic)
      Converts a field ID derived from cls to a Field object.
      Parameters:
      isStatic - must be set to TRUE if fieldID refers to a static field, and FALSE otherwise
    • NewGlobalRef

      public static long NewGlobalRef(Object obj)
      Creates a new global reference to the object referred to by the obj argument. The obj argument may be a global or local reference. Global references must be explicitly disposed of by calling DeleteGlobalRef(long).
      Parameters:
      obj - a global or local reference
      Returns:
      a global reference, or NULL if 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 by globalRef.
      Parameters:
      globalRef - a global reference
    • nGetBooleanArrayElements

      public static long nGetBooleanArrayElements(byte[] array, long isCopy)
    • GetBooleanArrayElements

      @Nullable public static ByteBuffer GetBooleanArrayElements(byte[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseBooleanArrayElements(byte[], java.nio.ByteBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseBooleanArrayElements(byte[], java.nio.ByteBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseBooleanArrayElements

      public static void nReleaseBooleanArrayElements(byte[] array, long elems, int mode)
    • ReleaseBooleanArrayElements

      public static void ReleaseBooleanArrayElements(byte[] array, ByteBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetBooleanArrayElements(byte[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetByteArrayElements

      public static long nGetByteArrayElements(byte[] array, long isCopy)
    • GetByteArrayElements

      @Nullable public static ByteBuffer GetByteArrayElements(byte[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseByteArrayElements(byte[], java.nio.ByteBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseByteArrayElements(byte[], java.nio.ByteBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseByteArrayElements

      public static void nReleaseByteArrayElements(byte[] array, long elems, int mode)
    • ReleaseByteArrayElements

      public static void ReleaseByteArrayElements(byte[] array, ByteBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetByteArrayElements(byte[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetCharArrayElements

      public static long nGetCharArrayElements(char[] array, long isCopy)
    • GetCharArrayElements

      @Nullable public static ShortBuffer GetCharArrayElements(char[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseCharArrayElements(char[], java.nio.ShortBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseCharArrayElements(char[], java.nio.ShortBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseCharArrayElements

      public static void nReleaseCharArrayElements(char[] array, long elems, int mode)
    • ReleaseCharArrayElements

      public static void ReleaseCharArrayElements(char[] array, ShortBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetCharArrayElements(char[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetShortArrayElements

      public static long nGetShortArrayElements(short[] array, long isCopy)
    • GetShortArrayElements

      @Nullable public static ShortBuffer GetShortArrayElements(short[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseShortArrayElements(short[], java.nio.ShortBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseShortArrayElements(short[], java.nio.ShortBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseShortArrayElements

      public static void nReleaseShortArrayElements(short[] array, long elems, int mode)
    • ReleaseShortArrayElements

      public static void ReleaseShortArrayElements(short[] array, ShortBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetShortArrayElements(short[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetIntArrayElements

      public static long nGetIntArrayElements(int[] array, long isCopy)
    • GetIntArrayElements

      @Nullable public static IntBuffer GetIntArrayElements(int[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseIntArrayElements(int[], java.nio.IntBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseIntArrayElements(int[], java.nio.IntBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseIntArrayElements

      public static void nReleaseIntArrayElements(int[] array, long elems, int mode)
    • ReleaseIntArrayElements

      public static void ReleaseIntArrayElements(int[] array, IntBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetIntArrayElements(int[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetLongArrayElements

      public static long nGetLongArrayElements(long[] array, long isCopy)
    • GetLongArrayElements

      @Nullable public static LongBuffer GetLongArrayElements(long[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseLongArrayElements(long[], java.nio.LongBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseLongArrayElements(long[], java.nio.LongBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseLongArrayElements

      public static void nReleaseLongArrayElements(long[] array, long elems, int mode)
    • ReleaseLongArrayElements

      public static void ReleaseLongArrayElements(long[] array, LongBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetLongArrayElements(long[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetFloatArrayElements

      public static long nGetFloatArrayElements(float[] array, long isCopy)
    • GetFloatArrayElements

      @Nullable public static FloatBuffer GetFloatArrayElements(float[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseFloatArrayElements(float[], java.nio.FloatBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseFloatArrayElements(float[], java.nio.FloatBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseFloatArrayElements

      public static void nReleaseFloatArrayElements(float[] array, long elems, int mode)
    • ReleaseFloatArrayElements

      public static void ReleaseFloatArrayElements(float[] array, FloatBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetFloatArrayElements(float[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetDoubleArrayElements

      public static long nGetDoubleArrayElements(double[] array, long isCopy)
    • GetDoubleArrayElements

      @Nullable public static DoubleBuffer GetDoubleArrayElements(double[] array, @Nullable ByteBuffer isCopy)
      Returns the body of the primitive array. The result is valid until the ReleaseDoubleArrayElements(double[], java.nio.DoubleBuffer, int) function is called. Since the returned array may be a copy of the Java array, changes made to the returned array will not necessarily be reflected in the original array until ReleaseDoubleArrayElements(double[], java.nio.DoubleBuffer, int) is called.

      If isCopy is not NULL, then *isCopy is set to TRUE if a copy is made; or it is set to FALSE if no copy is made.

      Parameters:
      array - the primitive array
      isCopy - a pointer to a boolean
      Returns:
      a pointer to the array elements, or NULL if the operation fails
    • nReleaseDoubleArrayElements

      public static void nReleaseDoubleArrayElements(double[] array, long elems, int mode)
    • ReleaseDoubleArrayElements

      public static void ReleaseDoubleArrayElements(double[] array, DoubleBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the GetDoubleArrayElements(double[], java.nio.ByteBuffer) function. If necessary, this function copies back all changes made to elems to the original array.

      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:

      modeactions
      0copy 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.

      Parameters:
      array - a Java array object
      elems - a pointer to array elements
      mode - the release mode. One of:
      0COMMITABORT
    • nGetBooleanArrayRegion

      public static void nGetBooleanArrayRegion(byte[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetBooleanArrayRegion

      public static void GetBooleanArrayRegion(byte[] array, int start, ByteBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetBooleanArrayRegion

      public static void nSetBooleanArrayRegion(byte[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetBooleanArrayRegion

      public static void SetBooleanArrayRegion(byte[] array, int start, ByteBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nGetByteArrayRegion

      public static void nGetByteArrayRegion(byte[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetByteArrayRegion

      public static void GetByteArrayRegion(byte[] array, int start, ByteBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetByteArrayRegion

      public static void nSetByteArrayRegion(byte[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetByteArrayRegion

      public static void SetByteArrayRegion(byte[] array, int start, ByteBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nGetCharArrayRegion

      public static void nGetCharArrayRegion(char[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetCharArrayRegion

      public static void GetCharArrayRegion(char[] array, int start, ShortBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetCharArrayRegion

      public static void nSetCharArrayRegion(char[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetCharArrayRegion

      public static void SetCharArrayRegion(char[] array, int start, ShortBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nGetShortArrayRegion

      public static void nGetShortArrayRegion(short[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetShortArrayRegion

      public static void GetShortArrayRegion(short[] array, int start, ShortBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetShortArrayRegion

      public static void nSetShortArrayRegion(short[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetShortArrayRegion

      public static void SetShortArrayRegion(short[] array, int start, ShortBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nGetIntArrayRegion

      public static void nGetIntArrayRegion(int[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetIntArrayRegion

      public static void GetIntArrayRegion(int[] array, int start, IntBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetIntArrayRegion

      public static void nSetIntArrayRegion(int[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetIntArrayRegion

      public static void SetIntArrayRegion(int[] array, int start, IntBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nGetLongArrayRegion

      public static void nGetLongArrayRegion(long[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetLongArrayRegion

      public static void GetLongArrayRegion(long[] array, int start, LongBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetLongArrayRegion

      public static void nSetLongArrayRegion(long[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetLongArrayRegion

      public static void SetLongArrayRegion(long[] array, int start, LongBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nGetFloatArrayRegion

      public static void nGetFloatArrayRegion(float[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetFloatArrayRegion

      public static void GetFloatArrayRegion(float[] array, int start, FloatBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetFloatArrayRegion

      public static void nSetFloatArrayRegion(float[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetFloatArrayRegion

      public static void SetFloatArrayRegion(float[] array, int start, FloatBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nGetDoubleArrayRegion

      public static void nGetDoubleArrayRegion(double[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • GetDoubleArrayRegion

      public static void GetDoubleArrayRegion(double[] array, int start, DoubleBuffer buf)
      Copies a region of a primitive array into a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the destination buffer
    • nSetDoubleArrayRegion

      public static void nSetDoubleArrayRegion(double[] array, int start, int len, long buf)
      Parameters:
      len - the number of elements to be copied
    • SetDoubleArrayRegion

      public static void SetDoubleArrayRegion(double[] array, int start, DoubleBuffer buf)
      Copies back a region of a primitive array from a buffer.
      Parameters:
      array - a Java array
      start - the starting index
      buf - the source buffer
    • nRegisterNatives

      public static int nRegisterNatives(Class<?> targetClass, long methods, int nMethods)
      Parameters:
      nMethods - the number of native methods in the class
    • RegisterNatives

      public static int RegisterNatives(Class<?> targetClass, JNINativeMethod.Buffer methods)
      Registers native methods with the class specified by the targetClass argument. The methods parameter specifies an array of JNINativeMethod structures that contain the names, signatures, and function pointers of the native methods. The name and signature fields of the JNINativeMethod structure are pointers to modified UTF-8 strings. The nMethods parameter 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(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)
    • 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(String str, int start, int len, long buf)
    • GetStringRegion

      public static void GetStringRegion(String str, int start, ByteBuffer buf)
      Copies len number of Unicode characters beginning at offset start to the given buffer buf.
    • nGetStringUTFRegion

      public static void nGetStringUTFRegion(String str, int start, int len, long buf)
    • GetStringUTFRegion

      public static void GetStringUTFRegion(String str, int start, int len, ByteBuffer buf)
      Translates len number of Unicode characters beginning at offset start into modified UTF-8 encoding and place the result in the given buffer buf.
    • NewWeakGlobalRef

      public static long NewWeakGlobalRef(Object obj)
      Creates a new weak global reference. Returns NULL if obj refers to null, or if the VM runs out of memory. If the VM runs out of memory, an OutOfMemoryError will 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 ByteBuffer nNewDirectByteBuffer(long address, long capacity)
    • NewDirectByteBuffer

      @Nullable public static ByteBuffer NewDirectByteBuffer(long address, long capacity)
      Allocates and returns a direct java.nio.ByteBuffer referring to the block of memory starting at the memory address address and extending capacity bytes.

      Native code that calls this function and returns the resulting byte-buffer object to Java-level code should ensure that the buffer refers to a valid region of memory that is accessible for reading and, if appropriate, writing. An attempt to access an invalid memory location from Java code will either return an arbitrary value, have no visible effect, or cause an unspecified exception to be thrown.

      Parameters:
      address - the starting address of the memory region (must not be NULL)
      capacity - the size in bytes of the memory region (must be positive)
      Returns:
      a local reference to the newly-instantiated java.nio.ByteBuffer object. Returns NULL if an exception occurs, or if JNI access to direct buffers is not supported by this virtual machine.
    • GetDirectBufferAddress

      public static long GetDirectBufferAddress(Buffer buf)
      Fetches and returns the starting address of the memory region referenced by the given direct java.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 direct java.nio.Buffer object (must not be NULL)
      Returns:
      the starting address of the memory region referenced by the buffer. Returns NULL if the memory region is undefined, if the given object is not a direct java.nio.Buffer, or if JNI access to direct buffers is not supported by this virtual machine.
    • GetObjectRefType

      public static int GetObjectRefType(Object obj)
      Returns the type of the object referred to by the obj argument. The argument obj can 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.