Class JNINativeInterface



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

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

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

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

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void DeleteGlobalRef(long globalRef)
      Deletes the global reference pointed to by globalRef.
      static void DeleteWeakGlobalRef(long weakGlobalRef)
      Delete the VM resources needed for the given weak global reference.
      static long FromReflectedField(java.lang.reflect.Field field)
      Converts a Field to a field ID.
      static long FromReflectedMethod(java.lang.reflect.Method method)
      Converts a Method or Constructor object to a method ID.
      static java.nio.ByteBuffer GetBooleanArrayElements(byte[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
      Copies a region of a primitive array into a buffer.
      static java.nio.ByteBuffer GetByteArrayElements(byte[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
      Copies a region of a primitive array into a buffer.
      static java.nio.ShortBuffer GetCharArrayElements(char[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)
      Copies a region of a primitive array into a buffer.
      static long GetDirectBufferAddress(java.nio.Buffer buf)
      Fetches and returns the starting address of the memory region referenced by the given direct java.nio.Buffer.
      static java.nio.DoubleBuffer GetDoubleArrayElements(double[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)
      Copies a region of a primitive array into a buffer.
      static java.nio.FloatBuffer GetFloatArrayElements(float[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)
      Copies a region of a primitive array into a buffer.
      static java.nio.IntBuffer GetIntArrayElements(int[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)
      Copies a region of a primitive array into a buffer.
      static int GetJavaVM(PointerBuffer vm)
      Returns the Java VM interface (used in the Invocation API) associated with the current thread.
      static java.nio.LongBuffer GetLongArrayElements(long[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)
      Copies a region of a primitive array into a buffer.
      static int GetObjectRefType(java.lang.Object obj)
      Returns the type of the object referred to by the obj argument.
      static java.nio.ShortBuffer GetShortArrayElements(short[] array, java.nio.ByteBuffer isCopy)
      Returns the body of the primitive array.
      static void GetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)
      Copies a region of a primitive array into a buffer.
      static void GetStringRegion(java.lang.String str, int start, java.nio.ByteBuffer buf)
      Copies len number of Unicode characters beginning at offset start to the given buffer buf.
      static void GetStringUTFRegion(java.lang.String str, int start, int len, java.nio.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.
      static int GetVersion()
      Returns the version of the native method interface.
      static java.nio.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.
      static long NewGlobalRef(java.lang.Object obj)
      Creates a new global reference to the object referred to by the obj argument.
      static long NewWeakGlobalRef(java.lang.Object obj)
      Creates a new weak global reference.
      static int RegisterNatives(java.lang.Class<?> targetClass, JNINativeMethod.Buffer methods)
      Registers native methods with the class specified by the targetClass argument.
      static void ReleaseBooleanArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void ReleaseByteArrayElements(byte[] array, java.nio.ByteBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void ReleaseCharArrayElements(char[] array, java.nio.ShortBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void ReleaseDoubleArrayElements(double[] array, java.nio.DoubleBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void ReleaseFloatArrayElements(float[] array, java.nio.FloatBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void ReleaseIntArrayElements(int[] array, java.nio.IntBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void ReleaseLongArrayElements(long[] array, java.nio.LongBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void ReleaseShortArrayElements(short[] array, java.nio.ShortBuffer elems, int mode)
      Informs the VM that the native code no longer needs access to elems.
      static void SetBooleanArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static void SetByteArrayRegion(byte[] array, int start, java.nio.ByteBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static void SetCharArrayRegion(char[] array, int start, java.nio.ShortBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static void SetDoubleArrayRegion(double[] array, int start, java.nio.DoubleBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static void SetFloatArrayRegion(float[] array, int start, java.nio.FloatBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static void SetIntArrayRegion(int[] array, int start, java.nio.IntBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static void SetLongArrayRegion(long[] array, int start, java.nio.LongBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static void SetShortArrayRegion(short[] array, int start, java.nio.ShortBuffer buf)
      Copies back a region of a primitive array from a buffer.
      static java.lang.reflect.Field ToReflectedField(java.lang.Class<?> cls, long fieldID, boolean isStatic)
      Converts a field ID derived from cls to a Field object.
      static java.lang.reflect.Method ToReflectedMethod(java.lang.Class<?> cls, long methodID, boolean isStatic)
      Converts a method ID derived from cls to a Method or Constructor object.
      static int UnregisterNatives(java.lang.Class<?> targetClass)
      Unregisters native methods of a class.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 a Method or Constructor object to a method ID.
        Parameters:
        method -
      • FromReflectedField

        public static long FromReflectedField(java.lang.reflect.Field field)
        Converts a Field to a field ID.
        Parameters:
        field -
      • ToReflectedMethod

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

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

        public static long NewGlobalRef(java.lang.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 JNINativeInterface.DeleteGlobalRef(long).
        Parameters:
        obj - a global or local reference
        Returns:
        a global reference, or NULL if the system runs out of memory
      • DeleteGlobalRef

        public static void DeleteGlobalRef(long globalRef)
        Deletes the global reference pointed to by globalRef.
        Parameters:
        globalRef - a global reference
      • ReleaseBooleanArrayElements

        public static void ReleaseBooleanArrayElements(byte[] array,
                                                       java.nio.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 JNINativeInterface.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
      • ReleaseByteArrayElements

        public static void ReleaseByteArrayElements(byte[] array,
                                                    java.nio.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 JNINativeInterface.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
      • ReleaseCharArrayElements

        public static void ReleaseCharArrayElements(char[] array,
                                                    java.nio.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 JNINativeInterface.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
      • ReleaseShortArrayElements

        public static void ReleaseShortArrayElements(short[] array,
                                                     java.nio.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 JNINativeInterface.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
      • ReleaseIntArrayElements

        public static void ReleaseIntArrayElements(int[] array,
                                                   java.nio.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 JNINativeInterface.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
      • ReleaseLongArrayElements

        public static void ReleaseLongArrayElements(long[] array,
                                                    java.nio.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 JNINativeInterface.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
      • ReleaseFloatArrayElements

        public static void ReleaseFloatArrayElements(float[] array,
                                                     java.nio.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 JNINativeInterface.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
      • ReleaseDoubleArrayElements

        public static void ReleaseDoubleArrayElements(double[] array,
                                                      java.nio.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 JNINativeInterface.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
      • 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 array
        start - the starting index
        buf - the destination buffer
      • SetBooleanArrayRegion

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        public static int RegisterNatives(java.lang.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:
        targetClass -
        methods - the native methods in the class
        Returns:
        “0” on success; returns a negative value on failure
      • UnregisterNatives

        public static int UnregisterNatives(java.lang.Class<?> targetClass)
        Unregisters native methods of a class. The class goes back to the state before it was linked or registered with its native method functions.

        This function should not be used in normal native code. Instead, it provides special programs a way to reload and relink native libraries.

        Parameters:
        targetClass - a Java class object
        Returns:
        “0” on success; returns a negative value on failure
      • GetJavaVM

        public static int GetJavaVM(PointerBuffer vm)
        Returns the Java VM interface (used in the Invocation API) associated with the current thread. The result is placed at the location pointed to by the second argument, vm.
        Parameters:
        vm - a pointer to where the result should be placed
      • GetStringRegion

        public static void GetStringRegion(java.lang.String str,
                                           int start,
                                           java.nio.ByteBuffer buf)
        Copies len number of Unicode characters beginning at offset start to the given buffer buf.
        Parameters:
        str -
        start -
        buf -
      • GetStringUTFRegion

        public static void GetStringUTFRegion(java.lang.String str,
                                              int start,
                                              int len,
                                              java.nio.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.
        Parameters:
        str -
        start -
        len -
        buf -
      • NewWeakGlobalRef

        public static long NewWeakGlobalRef(java.lang.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.
        Parameters:
        obj -
      • DeleteWeakGlobalRef

        public static void DeleteWeakGlobalRef(long weakGlobalRef)
        Delete the VM resources needed for the given weak global reference.
        Parameters:
        weakGlobalRef -
      • NewDirectByteBuffer

        public static java.nio.ByteBuffer NewDirectByteBuffer(long address,
                                                              long capacity)
        Allocates and returns a 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(java.nio.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(java.lang.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