Package com.kenai.jffi
Class Foreign
- java.lang.Object
-
- com.kenai.jffi.Foreign
-
final class Foreign extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Foreign.InstanceHolder
private static class
Foreign.InValidInstanceHolder
private static class
Foreign.ValidInstanceHolder
-
Field Summary
Fields Modifier and Type Field Description static int
F_DEFAULT
Default calling conventionstatic int
F_NOERRNO
Do not save errno after each callstatic int
F_PROTECT
Try to capture segmentation faults and convert to java exceptionsstatic int
F_STDCALL
Windows STDCALL calling conventionstatic int
JNI_EDETACHED
static int
JNI_EEXIST
static int
JNI_EINVAL
static int
JNI_ENOMEM
static int
JNI_ERR
static int
JNI_EVERSION
static int
JNI_OK
static int
MAP_ALIGN
static int
MAP_ANON
static int
MAP_FIXED
Use the specified addressstatic int
MAP_NORESERVE
static int
MAP_PRIVATE
static int
MAP_SHARED
Share changesstatic int
MAP_TEXT
Code segment memorystatic int
MEM_4MB_PAGES
static int
MEM_COMMIT
static int
MEM_DECOMMIT
static int
MEM_FREE
static int
MEM_MAPPED
static int
MEM_PHYSICAL
static int
MEM_PRIVATE
static int
MEM_RELEASE
static int
MEM_RESERVE
static int
MEM_RESET
static int
MEM_TOP_DOWN
static int
PAGE_EXECUTE
static int
PAGE_EXECUTE_READ
static int
PAGE_EXECUTE_READWRITE
static int
PAGE_EXECUTE_WRITECOPY
static int
PAGE_NOACCESS
Win32 VirtualAlloc/VirtualProtect flagsstatic int
PAGE_READONLY
static int
PAGE_READWRITE
static int
PAGE_WRITECOPY
static int
PROT_EXEC
Pages can be executedstatic int
PROT_NONE
Pages cannot be accessedstatic int
PROT_READ
Pages can be readstatic int
PROT_WRITE
Pages can be writtenstatic int
RTLD_GLOBAL
All symbols in the library are made available to other librariesstatic int
RTLD_LAZY
Perform lazy binding.static int
RTLD_LOCAL
Symbols in this library are not made available to other librariesstatic int
RTLD_NOW
Resolve all symbols when loading the librarystatic int
TYPE_DOUBLE
static int
TYPE_FLOAT
static int
TYPE_LONGDOUBLE
static int
TYPE_POINTER
static int
TYPE_SCHAR
static int
TYPE_SINT
static int
TYPE_SINT16
static int
TYPE_SINT32
static int
TYPE_SINT64
static int
TYPE_SINT8
static int
TYPE_SLONG
static int
TYPE_SSHORT
static int
TYPE_STRUCT
static int
TYPE_UCHAR
static int
TYPE_UINT
static int
TYPE_UINT16
static int
TYPE_UINT32
static int
TYPE_UINT64
static int
TYPE_UINT8
static int
TYPE_ULONG
static int
TYPE_USHORT
static int
TYPE_VOID
static int
VERSION_MAJOR
static int
VERSION_MICRO
static int
VERSION_MINOR
-
Constructor Summary
Constructors Modifier Constructor Description private
Foreign()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static long
allocateMemory(long size, boolean clear)
Allocates native memory.(package private) java.lang.Object
allocObject(java.lang.Class clazz)
(package private) long
closureMagazineGet(long closurePool, java.lang.Object proxy)
(package private) long
compileNativeMethods(long[] methods)
(package private) static void
copyMemory(long src, long dst, long size)
Copies contents of a native memory location to another native memory location.(package private) static void
copyMemoryChecked(long src, long dst, long size)
Copies contents of a native memory location to another native memory location.(package private) java.lang.Class
defineClass(java.lang.String name, java.lang.Object loader, byte[] buf, int off, int len)
(package private) java.lang.Class
defineClass(java.lang.String name, java.lang.Object loader, java.nio.ByteBuffer buf)
(package private) static void
dlclose(long handle)
Closes a dynamic library opened bydlopen(java.lang.String, int)
.(package private) static java.lang.String
dlerror()
Gets the last error raised bydlopen(java.lang.String, int)
ordlsym(long, java.lang.String)
(package private) static long
dlopen(java.lang.String name, int flags)
Opens a dynamic library.(package private) static long
dlsym(long handle, java.lang.String name)
Locates the memory address of a dynamic library symbol.(package private) void
fatalError(java.lang.String msg)
(package private) void
freeAggregate(long handle)
Frees a FFI struct, union or array handle allocated vianewStruct(long[], boolean)
ornewArray(long, int)
.(package private) void
freeCallContext(long callContext)
Frees a call context created bynewCallContext(long, long[], int)
(package private) void
freeClosureMagazine(long closurePool)
(package private) void
freeCompiledMethods(long handle)
(package private) static void
freeMemory(long address)
Releases memory allocated viaallocateMemory(long, boolean)
back to the system.(package private) void
freeNativeMethod(long handle)
(package private) static long
getAddress(long address)
Reads a native memory address from a native memory location.(package private) static long
getAddressChecked(long address)
Reads a native memory address from a native memory location.(package private) java.lang.String
getArch()
(package private) static byte
getByte(long address)
Reads an 8 bit integer from a native memory location.(package private) static void
getByteArray(long address, byte[] data, int offset, int length)
Reads a java byte array from native memory.(package private) static void
getByteArrayChecked(long address, byte[] data, int offset, int length)
Reads a java byte array from native memory.(package private) static byte
getByteChecked(long address)
Reads an 8 bit integer from a native memory location.(package private) int
getCallContextRawParameterSize(long callContext)
Gets the size required to pack parameters for the function in libffi raw format.(package private) static void
getCharArray(long address, char[] data, int offset, int length)
Reads a java char array from native memory.(package private) static void
getCharArrayChecked(long address, char[] data, int offset, int length)
Reads a java char array from native memory.(package private) long
getDirectBufferAddress(java.nio.Buffer buffer)
Gets the native memory address of a direct ByteBuffer(package private) static double
getDouble(long address)
Reads a 64 bit floating point value from a native memory location.(package private) static void
getDoubleArray(long address, double[] data, int offset, int length)
Reads a java double array from native memory.(package private) static void
getDoubleArrayChecked(long address, double[] data, int offset, int length)
Reads a java double array from native memory.(package private) static double
getDoubleChecked(long address)
Reads a 64 bit floating point value from a native memory location.(package private) static float
getFloat(long address)
Reads a 32 bit floating point value from a native memory location.(package private) static void
getFloatArray(long address, float[] data, int offset, int length)
Reads a java float array from native memory.(package private) static void
getFloatArrayChecked(long address, float[] data, int offset, int length)
Reads a java float array from native memory.(package private) static float
getFloatChecked(long address)
Reads a 32 bit floating point value from a native memory location.static Foreign
getInstance()
(package private) static int
getInt(long address)
Reads a 32 bit integer from a native memory location.(package private) static void
getIntArray(long address, int[] data, int offset, int length)
Reads a java int array from native memory.(package private) static void
getIntArrayChecked(long address, int[] data, int offset, int length)
Reads a java int array from native memory.(package private) static int
getIntChecked(long address)
Reads a 32 bit integer from a native memory location.(package private) long
getJavaVM()
(package private) int
getJNIVersion()
(package private) static int
getLastError()
Gets the last error returned by a native function(package private) static long
getLong(long address)
Reads a 64 bit integer from a native memory location.(package private) static void
getLongArray(long address, long[] data, int offset, int length)
Reads a java long array from native memory.(package private) static void
getLongArrayChecked(long address, long[] data, int offset, int length)
Reads a java long array from native memory.(package private) static long
getLongChecked(long address)
Reads a 64 bit integer from a native memory location.(package private) long
getSaveErrnoCtxFunction()
(package private) long
getSaveErrnoFunction()
(package private) static short
getShort(long address)
Reads a 16 bit integer from a native memory location.(package private) static void
getShortArray(long address, short[] data, int offset, int length)
Reads a java short array from native memory.(package private) static void
getShortArrayChecked(long address, short[] data, int offset, int length)
Reads a java short array from native memory.(package private) static short
getShortChecked(long address)
Reads a 16 bit integer from a native memory location.(package private) int
getTypeAlign(long handle)
Gets the minimum required alignment of the FFI type(package private) int
getTypeSize(long handle)
Gets the native size of the type(package private) int
getTypeType(long handle)
Gets the primitive type enum for the FFI type(package private) int
getVersion()
Gets the native stub library version.private static int
getVersionField(java.lang.String name)
(package private) static byte[]
getZeroTerminatedByteArray(long address)
Copies a zero (nul) terminated by array from native memory.(package private) static byte[]
getZeroTerminatedByteArray(long address, int maxlen)
Copies a zero (nul) terminated by array from native memory.(package private) static byte[]
getZeroTerminatedByteArrayChecked(long address)
Copies a zero Checked(nul) terminated by array from native memory.(package private) static byte[]
getZeroTerminatedByteArrayChecked(long address, int maxlen)
Copies a zero Checked(nul) terminated by array from native memory.private void
init()
Initializes any native method/field/class ids(package private) static int
invokeArrayO1Int32(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len)
(package private) static long
invokeArrayO1Int64(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len)
(package private) static int
invokeArrayO2Int32(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len, java.lang.Object o2, int o2info, int o2off, int o2len)
(package private) static long
invokeArrayO2Int64(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len, java.lang.Object o2, int o2info, int o2off, int o2len)
(package private) static double
invokeArrayReturnDouble(long callContext, long function, byte[] buffer)
Invokes a function that returns a 64 bit floating point value.(package private) static float
invokeArrayReturnFloat(long callContext, long function, byte[] buffer)
Invokes a function that returns a 32 bit floating point value.(package private) static int
invokeArrayReturnInt(long callContext, long function, byte[] buffer)
Invokes a function that returns a 32 bit integer.(package private) static long
invokeArrayReturnLong(long callContext, long function, byte[] buffer)
Invokes a function that returns a 64 bit integer.(package private) static void
invokeArrayReturnStruct(long callContext, long function, byte[] paramBuffer, byte[] returnBuffer, int offset)
Invokes a function and pack the return value into a byte array.(package private) static double
invokeArrayWithObjectsDouble(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
(package private) static float
invokeArrayWithObjectsFloat(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
(package private) static int
invokeArrayWithObjectsInt32(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
(package private) static long
invokeArrayWithObjectsInt64(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
(package private) static java.lang.Object
invokeArrayWithObjectsReturnObject(long callContext, long function, byte[] paramBuffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
Invokes a function that returns a java object.(package private) static void
invokeArrayWithObjectsReturnStruct(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects, byte[] returnBuffer, int returnBufferOffset)
(package private) static int
invokeI0(long callContext, long function)
Invokes a function with no arguments, and returns a 32 bit integer.(package private) static int
invokeI0NoErrno(long callContext, long function)
Invokes a function with no arguments, and returns a 32 bit integer.(package private) static int
invokeI1(long callContext, long function, int arg1)
Invokes a function with one integer argument, and returns a 32 bit integer.(package private) static int
invokeI1NoErrno(long callContext, long function, int arg1)
Invokes a function with one integer argument, and returns a 32 bit integer.(package private) static int
invokeI2(long callContext, long function, int arg1, int arg2)
Invokes a function with two integer arguments, and returns a 32 bit integer.(package private) static int
invokeI2NoErrno(long callContext, long function, int arg1, int arg2)
Invokes a function with two integer arguments, and returns a 32 bit integer.(package private) static int
invokeI3(long callContext, long function, int arg1, int arg2, int arg3)
Invokes a function with three integer arguments, and returns a 32 bit integer.(package private) static int
invokeI3NoErrno(long callContext, long function, int arg1, int arg2, int arg3)
Invokes a function with three integer arguments, and returns a 32 bit integer.(package private) static int
invokeI4(long callContext, long function, int arg1, int arg2, int arg3, int arg4)
Invokes a function with four integer arguments, and returns a 32 bit integer.(package private) static int
invokeI4NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4)
(package private) static int
invokeI5(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5)
Invokes a function with five integer arguments, and returns a 32 bit integer.(package private) static int
invokeI5NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5)
(package private) static int
invokeI6(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
Invokes a function with six integer arguments, and returns a 32 bit integer.(package private) static int
invokeI6NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
(package private) static long
invokeL0(long ctx, long function)
Invokes a function with no arguments, and returns a 64 bit integer.(package private) static long
invokeL0NoErrno(long ctx, long function)
(package private) static long
invokeL1(long ctx, long function, long arg1)
Invokes a function with one 64 bit integer argument, and returns a 64 bit integer.(package private) static long
invokeL1NoErrno(long ctx, long function, long arg1)
(package private) static long
invokeL2(long ctx, long function, long arg1, long arg2)
Invokes a function with two 64 bit integer arguments, and returns a 64 bit integer.(package private) static long
invokeL2NoErrno(long ctx, long function, long arg1, long arg2)
(package private) static long
invokeL3(long ctx, long function, long arg1, long arg2, long arg3)
Invokes a function with three 64 bit integer arguments, and returns a 64 bit integer.(package private) static long
invokeL3NoErrno(long ctx, long function, long arg1, long arg2, long arg3)
(package private) static long
invokeL4(long ctx, long function, long arg1, long arg2, long arg3, long arg4)
Invokes a function with four 64 bit integer arguments, and returns a 64 bit integer.(package private) static long
invokeL4NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4)
(package private) static long
invokeL5(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5)
Invokes a function with five 64 bit integer arguments, and returns a 64 bit integer.(package private) static long
invokeL5NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5)
(package private) static long
invokeL6(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
Invokes a function with six 64 bit integer arguments, and returns a 64 bit integer.(package private) static long
invokeL6NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
(package private) static long
invokeN0(long ctx, long function)
Invokes a function with zero numeric arguments, and returns a numeric value.(package private) static long
invokeN1(long ctx, long function, long arg1)
Invokes a function with one numeric arguments, and returns a numeric value.(package private) static long
invokeN1O1(long callContext, long functionAddress, long n1, java.lang.Object o1, int o1flags, int o1off, int o1len)
Invokes a function with one numeric argument, and returns a numeric value.(package private) static long
invokeN2(long ctx, long function, long arg1, long arg2)
Invokes a function with two numeric arguments, and returns a numeric value.(package private) static long
invokeN2O1(long callContext, long functionAddress, long n1, long n2, java.lang.Object o1, int o1flags, int o1off, int o1len)
Invokes a function with two numeric arguments, and returns a numeric value.(package private) static long
invokeN2O2(long callContext, long functionAddress, long n1, long n2, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
Invokes a function with two numeric arguments, and returns a numeric value.(package private) static long
invokeN3(long ctx, long function, long arg1, long arg2, long arg3)
Invokes a function with three numeric arguments, and returns a numeric value.(package private) static long
invokeN3O1(long callContext, long functionAddress, long n1, long n2, long n3, java.lang.Object o1, int o1flags, int o1off, int o1len)
Invokes a function with three numeric arguments, and returns a numeric value.(package private) static long
invokeN3O2(long callContext, long functionAddress, long n1, long n2, long n3, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
(package private) static long
invokeN3O3(long callContext, long functionAddress, long n1, long n2, long n3, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
(package private) static long
invokeN4(long ctx, long function, long arg1, long arg2, long arg3, long arg4)
Invokes a function with four numeric arguments, and returns a numeric value.(package private) static long
invokeN4O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len)
(package private) static long
invokeN4O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
(package private) static long
invokeN4O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
(package private) static long
invokeN4O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len)
(package private) static long
invokeN5(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5)
Invokes a function with five numeric arguments, and returns a numeric value.(package private) static long
invokeN5O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len)
(package private) static long
invokeN5O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
(package private) static long
invokeN5O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
(package private) static long
invokeN5O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len)
(package private) static long
invokeN5O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len, java.lang.Object o5, int o5flags, int o5off, int o5len)
(package private) static long
invokeN6(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
Invokes a function with six numeric arguments, and returns a numeric value.(package private) static long
invokeN6O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len)
(package private) static long
invokeN6O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
(package private) static long
invokeN6O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
(package private) static long
invokeN6O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len)
(package private) static long
invokeN6O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len, java.lang.Object o5, int o5flags, int o5off, int o5len)
(package private) static long
invokeN6O6(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len, java.lang.Object o5, int o5flags, int o5off, int o5len, java.lang.Object o6, int o6flags, int o6off, int o6len)
(package private) static void
invokePointerParameterArray(long callContext, long functionContext, long returnBuffer, long[] parameters)
Invokes a function, with the parameters loaded into native memory buffers, and the function result is stored in a native memory buffer.private static boolean
isFaultProtectionEnabled()
(package private) static boolean
isMemoryProtectionEnabled()
(package private) boolean
isRawParameterPackingEnabled()
(package private) void
longDoubleFromDouble(double doubleValue, byte[] buf, int off, int len)
(package private) void
longDoubleFromString(java.lang.String doubleString, byte[] buf, int off, int len)
(package private) double
longDoubleToDouble(byte[] buf, int off, int len)
(package private) java.lang.String
longDoubleToEngineeringString(byte[] buf, int off, int len)
(package private) java.lang.String
longDoubleToPlainString(byte[] buf, int off, int len)
(package private) java.lang.String
longDoubleToString(byte[] buf, int off, int len)
(package private) long
lookupBuiltinType(int type)
Gets the address of the ffi_type structure for the builtin type(package private) static long
memchr(long address, int value, long len)
Gets the address of a byte value in a native memory region.(package private) static long
memchrChecked(long address, int value, long len)
Gets the address of a byte value in a native memory region.(package private) static void
memcpy(long dst, long src, long len)
Copies non-overlapping memory areas.(package private) static void
memcpyChecked(long dst, long src, long len)
Copies non-overlapping memory areas.(package private) static void
memmove(long dst, long src, long len)
Copies potentially overlapping memory areas.(package private) static void
memmoveChecked(long dst, long src, long len)
Copies potentially overlapping memory areas.(package private) static long
mmap(long addr, long len, int prot, int flags, int fd, long off)
Calls the Unix mmap(2) function This method is undefined on windows.(package private) static int
mprotect(long addr, long len, int prot)
Calls the Unix mprotect(2) function.(package private) static int
munmap(long addr, long len)
Calls the Unix munmap(2) function.(package private) long
newArray(long elementType, int length)
Allocates a new FFI array type.(package private) long
newCallContext(long returnType, long[] paramTypes, int flags)
Creates a new native call context.(package private) long
newClosureMagazine(long contextAddress, java.lang.reflect.Method closureMethod, boolean callWithPrimitiveParameters)
(package private) java.nio.ByteBuffer
newDirectByteBuffer(long address, int capacity)
Creates a new Direct ByteBuffer for a native memory region.private static java.lang.UnsatisfiedLinkError
newLoadError(java.lang.Throwable cause)
(package private) long
newNativeMethod(java.lang.String name, java.lang.String signature, long functionContext)
(package private) long
newStruct(long[] fields, boolean isUnion)
Allocates a new FFI struct or union layout(package private) static long
pageSize()
Gets the size of a page of memory.(package private) static void
putAddress(long address, long value)
Writes a native memory address value to a native memory location.(package private) static void
putAddressChecked(long address, long value)
Writes a native memory address value to a native memory location.(package private) static void
putByte(long address, byte value)
Writes an 8 bit integer value to a native memory location.(package private) static void
putByteArray(long address, byte[] data, int offset, int length)
Writes a java byte array to native memory.(package private) static void
putByteArrayChecked(long address, byte[] data, int offset, int length)
Writes a java byte array to native memory.(package private) static void
putByteChecked(long address, byte value)
Writes an 8 bit integer value to a native memory location.(package private) static void
putCharArray(long address, char[] data, int offset, int length)
Writes a java char array to native memory.(package private) static void
putCharArrayChecked(long address, char[] data, int offset, int length)
Writes a java char array to native memory.(package private) static void
putDouble(long address, double value)
Writes a 64 bit floating point value to a native memory location.(package private) static void
putDoubleArray(long address, double[] data, int offset, int length)
Writes a java double array to native memory.(package private) static void
putDoubleArrayChecked(long address, double[] data, int offset, int length)
Writes a java double array to native memory.(package private) static void
putDoubleChecked(long address, double value)
Writes a 64 bit floating point value to a native memory location.(package private) static void
putFloat(long address, float value)
Writes a 32 bit floating point value to a native memory location.(package private) static void
putFloatArray(long address, float[] data, int offset, int length)
Writes a java double array to native memory.(package private) static void
putFloatArrayChecked(long address, float[] data, int offset, int length)
Writes a java double array to native memory.(package private) static void
putFloatChecked(long address, float value)
Writes a 32 bit floating point value to a native memory location.(package private) static void
putInt(long address, int value)
Writes a 32 bit integer value to a native memory location.(package private) static void
putIntArray(long address, int[] data, int offset, int length)
Writes a java int array to native memory.(package private) static void
putIntArrayChecked(long address, int[] data, int offset, int length)
Writes a java int array to native memory.(package private) static void
putIntChecked(long address, int value)
Writes a 32 bit integer value to a native memory location.(package private) static void
putLong(long address, long value)
Writes a 64 bit integer value to a native memory location.(package private) static void
putLongArray(long address, long[] data, int offset, int length)
Writes a java long array to native memory.(package private) static void
putLongArrayChecked(long address, long[] data, int offset, int length)
Writes a java long array to native memory.(package private) static void
putLongChecked(long address, long value)
Writes a 64 bit integer value to a native memory location.(package private) static void
putShort(long address, short value)
Writes a 16 bit integer value to a native memory location.(package private) static void
putShortArray(long address, short[] data, int offset, int length)
Writes a java short array to native memory.(package private) static void
putShortArrayChecked(long address, short[] data, int offset, int length)
Writes a java short array to native memory.(package private) static void
putShortChecked(long address, short value)
Writes a 16 bit integer value to a native memory location.(package private) static void
putZeroTerminatedByteArray(long address, byte[] data, int offset, int length)
Copies a java byte array to native memory and appends a NUL terminating byte.(package private) static void
putZeroTerminatedByteArrayChecked(long address, byte[] data, int offset, int length)
Copies a java byte array to native memory and appends a NUL terminating byte.(package private) boolean
registerNativeMethods(java.lang.Class clazz, long handle)
(package private) int
registerNatives(java.lang.Class clazz, long methods, int methodCount)
(package private) void
setCallContextErrorFunction(long ctx, long fn)
(package private) static void
setLastError(int error)
Sets the native errno value(package private) static void
setMemory(long address, long size, byte value)
Sets a region of native memory to a specific byte value.(package private) static void
setMemoryChecked(long address, long size, byte value)
Sets a region of native memory to a specific byte value.(package private) static long
strlen(long address)
Gets the length of a native ascii or utf-8 string.(package private) static long
strlenChecked(long address)
Gets the length of a native ascii or utf-8 string.(package private) void
unregisterNativeMethods(java.lang.Class clazz)
(package private) int
unregisterNatives(java.lang.Class clazz)
(package private) static long
VirtualAlloc(long addr, int size, int flags, int prot)
(package private) static boolean
VirtualFree(long addr, int size, int flags)
(package private) static boolean
VirtualProtect(long addr, int size, int prot)
-
-
-
Field Detail
-
VERSION_MAJOR
@Native public static final int VERSION_MAJOR
-
VERSION_MINOR
@Native public static final int VERSION_MINOR
-
VERSION_MICRO
@Native public static final int VERSION_MICRO
-
TYPE_VOID
@Native public static final int TYPE_VOID
- See Also:
- Constant Field Values
-
TYPE_FLOAT
@Native public static final int TYPE_FLOAT
- See Also:
- Constant Field Values
-
TYPE_DOUBLE
@Native public static final int TYPE_DOUBLE
- See Also:
- Constant Field Values
-
TYPE_LONGDOUBLE
@Native public static final int TYPE_LONGDOUBLE
- See Also:
- Constant Field Values
-
TYPE_UINT8
@Native public static final int TYPE_UINT8
- See Also:
- Constant Field Values
-
TYPE_SINT8
@Native public static final int TYPE_SINT8
- See Also:
- Constant Field Values
-
TYPE_UINT16
@Native public static final int TYPE_UINT16
- See Also:
- Constant Field Values
-
TYPE_SINT16
@Native public static final int TYPE_SINT16
- See Also:
- Constant Field Values
-
TYPE_UINT32
@Native public static final int TYPE_UINT32
- See Also:
- Constant Field Values
-
TYPE_SINT32
@Native public static final int TYPE_SINT32
- See Also:
- Constant Field Values
-
TYPE_UINT64
@Native public static final int TYPE_UINT64
- See Also:
- Constant Field Values
-
TYPE_SINT64
@Native public static final int TYPE_SINT64
- See Also:
- Constant Field Values
-
TYPE_STRUCT
@Native public static final int TYPE_STRUCT
- See Also:
- Constant Field Values
-
TYPE_POINTER
@Native public static final int TYPE_POINTER
- See Also:
- Constant Field Values
-
TYPE_UCHAR
@Native public static final int TYPE_UCHAR
- See Also:
- Constant Field Values
-
TYPE_SCHAR
@Native public static final int TYPE_SCHAR
- See Also:
- Constant Field Values
-
TYPE_USHORT
@Native public static final int TYPE_USHORT
- See Also:
- Constant Field Values
-
TYPE_SSHORT
@Native public static final int TYPE_SSHORT
- See Also:
- Constant Field Values
-
TYPE_UINT
@Native public static final int TYPE_UINT
- See Also:
- Constant Field Values
-
TYPE_SINT
@Native public static final int TYPE_SINT
- See Also:
- Constant Field Values
-
TYPE_ULONG
@Native public static final int TYPE_ULONG
- See Also:
- Constant Field Values
-
TYPE_SLONG
@Native public static final int TYPE_SLONG
- See Also:
- Constant Field Values
-
RTLD_LAZY
@Native public static final int RTLD_LAZY
Perform lazy binding. Only resolve symbols as needed- See Also:
- Constant Field Values
-
RTLD_NOW
@Native public static final int RTLD_NOW
Resolve all symbols when loading the library- See Also:
- Constant Field Values
-
RTLD_LOCAL
@Native public static final int RTLD_LOCAL
Symbols in this library are not made available to other libraries- See Also:
- Constant Field Values
-
RTLD_GLOBAL
@Native public static final int RTLD_GLOBAL
All symbols in the library are made available to other libraries- See Also:
- Constant Field Values
-
PROT_READ
@Native public static final int PROT_READ
Pages can be read- See Also:
- Constant Field Values
-
PROT_WRITE
@Native public static final int PROT_WRITE
Pages can be written- See Also:
- Constant Field Values
-
PROT_EXEC
@Native public static final int PROT_EXEC
Pages can be executed- See Also:
- Constant Field Values
-
PROT_NONE
@Native public static final int PROT_NONE
Pages cannot be accessed- See Also:
- Constant Field Values
-
MAP_SHARED
@Native public static final int MAP_SHARED
Share changes- See Also:
- Constant Field Values
-
MAP_PRIVATE
@Native public static final int MAP_PRIVATE
- See Also:
- Constant Field Values
-
MAP_FIXED
@Native public static final int MAP_FIXED
Use the specified address- See Also:
- Constant Field Values
-
MAP_NORESERVE
@Native public static final int MAP_NORESERVE
- See Also:
- Constant Field Values
-
MAP_ANON
@Native public static final int MAP_ANON
- See Also:
- Constant Field Values
-
MAP_ALIGN
@Native public static final int MAP_ALIGN
- See Also:
- Constant Field Values
-
MAP_TEXT
@Native public static final int MAP_TEXT
Code segment memory- See Also:
- Constant Field Values
-
PAGE_NOACCESS
@Native public static final int PAGE_NOACCESS
Win32 VirtualAlloc/VirtualProtect flags- See Also:
- Constant Field Values
-
PAGE_READONLY
@Native public static final int PAGE_READONLY
- See Also:
- Constant Field Values
-
PAGE_READWRITE
@Native public static final int PAGE_READWRITE
- See Also:
- Constant Field Values
-
PAGE_WRITECOPY
@Native public static final int PAGE_WRITECOPY
- See Also:
- Constant Field Values
-
PAGE_EXECUTE
@Native public static final int PAGE_EXECUTE
- See Also:
- Constant Field Values
-
PAGE_EXECUTE_READ
@Native public static final int PAGE_EXECUTE_READ
- See Also:
- Constant Field Values
-
PAGE_EXECUTE_READWRITE
@Native public static final int PAGE_EXECUTE_READWRITE
- See Also:
- Constant Field Values
-
PAGE_EXECUTE_WRITECOPY
@Native public static final int PAGE_EXECUTE_WRITECOPY
- See Also:
- Constant Field Values
-
MEM_COMMIT
@Native public static final int MEM_COMMIT
- See Also:
- Constant Field Values
-
MEM_RESERVE
@Native public static final int MEM_RESERVE
- See Also:
- Constant Field Values
-
MEM_DECOMMIT
@Native public static final int MEM_DECOMMIT
- See Also:
- Constant Field Values
-
MEM_RELEASE
@Native public static final int MEM_RELEASE
- See Also:
- Constant Field Values
-
MEM_FREE
@Native public static final int MEM_FREE
- See Also:
- Constant Field Values
-
MEM_PRIVATE
@Native public static final int MEM_PRIVATE
- See Also:
- Constant Field Values
-
MEM_MAPPED
@Native public static final int MEM_MAPPED
- See Also:
- Constant Field Values
-
MEM_RESET
@Native public static final int MEM_RESET
- See Also:
- Constant Field Values
-
MEM_TOP_DOWN
@Native public static final int MEM_TOP_DOWN
- See Also:
- Constant Field Values
-
MEM_PHYSICAL
@Native public static final int MEM_PHYSICAL
- See Also:
- Constant Field Values
-
MEM_4MB_PAGES
@Native public static final int MEM_4MB_PAGES
- See Also:
- Constant Field Values
-
JNI_OK
public static final int JNI_OK
- See Also:
- Constant Field Values
-
JNI_ERR
public static final int JNI_ERR
- See Also:
- Constant Field Values
-
JNI_EDETACHED
public static final int JNI_EDETACHED
- See Also:
- Constant Field Values
-
JNI_EVERSION
public static final int JNI_EVERSION
- See Also:
- Constant Field Values
-
JNI_ENOMEM
public static final int JNI_ENOMEM
- See Also:
- Constant Field Values
-
JNI_EEXIST
public static final int JNI_EEXIST
- See Also:
- Constant Field Values
-
JNI_EINVAL
public static final int JNI_EINVAL
- See Also:
- Constant Field Values
-
F_DEFAULT
@Native public static final int F_DEFAULT
Default calling convention- See Also:
- Constant Field Values
-
F_STDCALL
@Native public static final int F_STDCALL
Windows STDCALL calling convention- See Also:
- Constant Field Values
-
F_NOERRNO
@Native public static final int F_NOERRNO
Do not save errno after each call- See Also:
- Constant Field Values
-
F_PROTECT
@Native public static final int F_PROTECT
Try to capture segmentation faults and convert to java exceptions- See Also:
- Constant Field Values
-
-
Method Detail
-
newLoadError
private static java.lang.UnsatisfiedLinkError newLoadError(java.lang.Throwable cause)
-
getInstance
public static Foreign getInstance()
-
getVersionField
private static int getVersionField(java.lang.String name)
-
getVersion
final int getVersion()
Gets the native stub library version.- Returns:
- The version in the form of (VERSION_MAJOR << 16 | VERSION_MINOR << 8 | VERSION_MICRO)
-
init
private void init()
Initializes any native method/field/class ids
-
isFaultProtectionEnabled
private static boolean isFaultProtectionEnabled()
-
isMemoryProtectionEnabled
static boolean isMemoryProtectionEnabled()
-
dlopen
static long dlopen(java.lang.String name, int flags)
Opens a dynamic library. This is a very thin wrapper around the native dlopen(3) call.- Parameters:
name
- The name of the dynamic library to open. Pass null to get a handle to the current process.flags
- The flags to dlopen. A bit mask ofRTLD_LAZY
,RTLD_NOW
,RTLD_LOCAL
,RTLD_GLOBAL
- Returns:
- A native handle to the dynamic library.
-
dlclose
static void dlclose(long handle)
Closes a dynamic library opened bydlopen(java.lang.String, int)
.- Parameters:
handle
- The dynamic library handle returned bydlopen(java.lang.String, int)
-
dlsym
static long dlsym(long handle, java.lang.String name)
Locates the memory address of a dynamic library symbol.- Parameters:
handle
- A dynamic library handle obtained fromdlopen(java.lang.String, int)
name
- The name of the symbol.- Returns:
- The address where the symbol in loaded in memory.
-
dlerror
static java.lang.String dlerror()
Gets the last error raised bydlopen(java.lang.String, int)
ordlsym(long, java.lang.String)
- Returns:
- The error string.
-
allocateMemory
static long allocateMemory(long size, boolean clear)
Allocates native memory.- Parameters:
size
- The number of bytes of memory to allocateclear
- Whether the memory should be cleared (each byte set to zero).- Returns:
- The native address of the allocated memory.
-
freeMemory
static void freeMemory(long address)
Releases memory allocated viaallocateMemory(long, boolean)
back to the system.- Parameters:
address
- The address of the memory to release.
-
pageSize
static long pageSize()
Gets the size of a page of memory.- Returns:
- The size of a memory page in bytes.
-
mmap
static long mmap(long addr, long len, int prot, int flags, int fd, long off)
Calls the Unix mmap(2) function This method is undefined on windows.- Parameters:
addr
- The desired address to map the memory at, or 0 for random address.len
- The length of the memory region.prot
- The protection mode for the memory region.flags
-fd
-off
-- Returns:
- The address of the mapping on success, -1 on error.
-
munmap
static int munmap(long addr, long len)
Calls the Unix munmap(2) function.- Parameters:
addr
- The address to unmap.len
- The size of the region.- Returns:
- 0 on success, -1 on error.
-
mprotect
static int mprotect(long addr, long len, int prot)
Calls the Unix mprotect(2) function.- Parameters:
addr
- The address to unmap.len
- The size of the region.prot
- The new protection mode.- Returns:
- 0 on success, -1 on error.
-
VirtualAlloc
static long VirtualAlloc(long addr, int size, int flags, int prot)
-
VirtualFree
static boolean VirtualFree(long addr, int size, int flags)
-
VirtualProtect
static boolean VirtualProtect(long addr, int size, int prot)
-
newCallContext
final long newCallContext(long returnType, long[] paramTypes, int flags)
Creates a new native call context. To allow calling variadic FFI logic, the number of fixed arguments is passed in the high word of the flags parameter. Older builds that do not use the variadic logic will ignore these bits and continue to use the non- variadic logic that already worked. This change was primarily made for Apple Silicon, which handles variadic arguments differently than other platforms.- Parameters:
returnType
- The return type of the functionparamTypes
- The types of the parametersflags
- A bitmask of F_DEFAULT, F_STDCALL, F_NOERRNO, F_PROTECT and the fixed param count in the high word.- Returns:
- The native address of a new function context
-
freeCallContext
final void freeCallContext(long callContext)
Frees a call context created bynewCallContext(long, long[], int)
- Parameters:
callContext
- The native call context to free
-
getCallContextRawParameterSize
final int getCallContextRawParameterSize(long callContext)
Gets the size required to pack parameters for the function in libffi raw format.- Parameters:
callContext
- The call context- Returns:
- The size in bytes required to pack parameters in raw format
-
isRawParameterPackingEnabled
final boolean isRawParameterPackingEnabled()
-
getLastError
static int getLastError()
Gets the last error returned by a native function- Returns:
- An integer.
-
setLastError
static void setLastError(int error)
Sets the native errno value- Parameters:
error
- The value to set errno to.
-
newClosureMagazine
final long newClosureMagazine(long contextAddress, java.lang.reflect.Method closureMethod, boolean callWithPrimitiveParameters)
-
freeClosureMagazine
final void freeClosureMagazine(long closurePool)
-
closureMagazineGet
final long closureMagazineGet(long closurePool, java.lang.Object proxy)
-
lookupBuiltinType
final long lookupBuiltinType(int type)
Gets the address of the ffi_type structure for the builtin type- Parameters:
type
- The FFI type enum value- Returns:
- The address of the ffi_type struct for this type, or
null
-
getTypeSize
final int getTypeSize(long handle)
Gets the native size of the type- Parameters:
handle
- Address of the type structure- Returns:
- The native size of the type
-
getTypeAlign
final int getTypeAlign(long handle)
Gets the minimum required alignment of the FFI type- Parameters:
handle
- Address of the type structure- Returns:
- The minimum required alignment
-
getTypeType
final int getTypeType(long handle)
Gets the primitive type enum for the FFI type- Parameters:
handle
- Address of the type structure- Returns:
- The builtin primitive type of the type structure
-
newStruct
final long newStruct(long[] fields, boolean isUnion)
Allocates a new FFI struct or union layout- Parameters:
fields
- An array of ffi_type pointers describing the fields of the structisUnion
- If true, then fields are all positioned at offset=0, else fields are sequentially positioned.- Returns:
- The native address of the ffi_type structure for the new struct layout
- See Also:
freeAggregate(long)
-
newArray
final long newArray(long elementType, int length)
Allocates a new FFI array type.- Parameters:
elementType
- the type of each element in the array.length
- the number of elements in the array.- Returns:
- The native address of the ffi_type structure for the new array layout.
- See Also:
freeAggregate(long)
-
freeAggregate
final void freeAggregate(long handle)
Frees a FFI struct, union or array handle allocated vianewStruct(long[], boolean)
ornewArray(long, int)
.- Parameters:
handle
- The FFI struct handle
-
invokeI0
static int invokeI0(long callContext, long function)
Invokes a function with no arguments, and returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.- Returns:
- A 32 bit integer value.
-
invokeI0NoErrno
static int invokeI0NoErrno(long callContext, long function)
Invokes a function with no arguments, and returns a 32 bit integer. This method does not save the errno value.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.- Returns:
- A 32 bit integer value.
-
invokeI1
static int invokeI1(long callContext, long function, int arg1)
Invokes a function with one integer argument, and returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI1NoErrno
static int invokeI1NoErrno(long callContext, long function, int arg1)
Invokes a function with one integer argument, and returns a 32 bit integer. This method does not save the errno value.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI2
static int invokeI2(long callContext, long function, int arg1, int arg2)
Invokes a function with two integer arguments, and returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The first 32 bit integer argument.arg2
- The second 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI2NoErrno
static int invokeI2NoErrno(long callContext, long function, int arg1, int arg2)
Invokes a function with two integer arguments, and returns a 32 bit integer. This method does not save the errno value.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The first 32 bit integer argument.arg2
- The second 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI3
static int invokeI3(long callContext, long function, int arg1, int arg2, int arg3)
Invokes a function with three integer arguments, and returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The first 32 bit integer argument.arg2
- The second 32 bit integer argument.arg3
- The third 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI4
static int invokeI4(long callContext, long function, int arg1, int arg2, int arg3, int arg4)
Invokes a function with four integer arguments, and returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The first 32 bit integer argument.arg2
- The second 32 bit integer argument.arg3
- The third 32 bit integer argument.arg4
- The third 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI5
static int invokeI5(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5)
Invokes a function with five integer arguments, and returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The first 32 bit integer argument.arg2
- The second 32 bit integer argument.arg3
- The third 32 bit integer argument.arg4
- The fourth 32 bit integer argument.arg5
- The fifth 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI6
static int invokeI6(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
Invokes a function with six integer arguments, and returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The first 32 bit integer argument.arg2
- The second 32 bit integer argument.arg3
- The third 32 bit integer argument.arg4
- The fourth 32 bit integer argument.arg5
- The fifth 32 bit integer argument.arg6
- The sixth 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI3NoErrno
static int invokeI3NoErrno(long callContext, long function, int arg1, int arg2, int arg3)
Invokes a function with three integer arguments, and returns a 32 bit integer. This method does not save the errno value.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.arg1
- The first 32 bit integer argument.arg2
- The second 32 bit integer argument.arg3
- The third 32 bit integer argument.- Returns:
- A 32 bit integer value.
-
invokeI4NoErrno
static int invokeI4NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4)
-
invokeI5NoErrno
static int invokeI5NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5)
-
invokeI6NoErrno
static int invokeI6NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
-
invokeL0
static long invokeL0(long ctx, long function)
Invokes a function with no arguments, and returns a 64 bit integer.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.- Returns:
- A 64 bit integer value.
-
invokeL1
static long invokeL1(long ctx, long function, long arg1)
Invokes a function with one 64 bit integer argument, and returns a 64 bit integer.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The 64 bit integer argument.- Returns:
- A 64 bit integer value.
-
invokeL2
static long invokeL2(long ctx, long function, long arg1, long arg2)
Invokes a function with two 64 bit integer arguments, and returns a 64 bit integer.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first 64 bit integer argument.arg2
- The second 64 bit integer argument.- Returns:
- A 64 bit integer value.
-
invokeL3
static long invokeL3(long ctx, long function, long arg1, long arg2, long arg3)
Invokes a function with three 64 bit integer arguments, and returns a 64 bit integer.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first 64 bit integer argument.arg2
- The second 64 bit integer argument.arg3
- The third 64 bit integer argument.- Returns:
- A 64 bit integer value.
-
invokeL4
static long invokeL4(long ctx, long function, long arg1, long arg2, long arg3, long arg4)
Invokes a function with four 64 bit integer arguments, and returns a 64 bit integer.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first 64 bit integer argument.arg2
- The second 64 bit integer argument.arg3
- The third 64 bit integer argument.arg4
- The fourth 64 bit integer argument.- Returns:
- A 64 bit integer value.
-
invokeL5
static long invokeL5(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5)
Invokes a function with five 64 bit integer arguments, and returns a 64 bit integer.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first 64 bit integer argument.arg2
- The second 64 bit integer argument.arg3
- The third 64 bit integer argument.arg4
- The fourth 64 bit integer argument.arg5
- The fifth 64 bit integer argument.- Returns:
- A 64 bit integer value.
-
invokeL6
static long invokeL6(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
Invokes a function with six 64 bit integer arguments, and returns a 64 bit integer.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first 64 bit integer argument.arg2
- The second 64 bit integer argument.arg3
- The third 64 bit integer argument.arg4
- The fourth 64 bit integer argument.arg5
- The fifth 64 bit integer argument.arg6
- The sixth 64 bit integer argument.- Returns:
- A 64 bit integer value.
-
invokeL0NoErrno
static long invokeL0NoErrno(long ctx, long function)
-
invokeL1NoErrno
static long invokeL1NoErrno(long ctx, long function, long arg1)
-
invokeL2NoErrno
static long invokeL2NoErrno(long ctx, long function, long arg1, long arg2)
-
invokeL3NoErrno
static long invokeL3NoErrno(long ctx, long function, long arg1, long arg2, long arg3)
-
invokeL4NoErrno
static long invokeL4NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4)
-
invokeL5NoErrno
static long invokeL5NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5)
-
invokeL6NoErrno
static long invokeL6NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
-
invokeN0
static long invokeN0(long ctx, long function)
Invokes a function with zero numeric arguments, and returns a numeric value.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.- Returns:
- A numeric value.
-
invokeN1
static long invokeN1(long ctx, long function, long arg1)
Invokes a function with one numeric arguments, and returns a numeric value.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first numeric argument.- Returns:
- A numeric value.
-
invokeN2
static long invokeN2(long ctx, long function, long arg1, long arg2)
Invokes a function with two numeric arguments, and returns a numeric value.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first numeric argument.arg2
- The second numeric argument.- Returns:
- A numeric value.
-
invokeN3
static long invokeN3(long ctx, long function, long arg1, long arg2, long arg3)
Invokes a function with three numeric arguments, and returns a numeric value.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first numeric argument.arg2
- The second numeric argument.arg3
- The third numeric argument.- Returns:
- A numeric value.
-
invokeN4
static long invokeN4(long ctx, long function, long arg1, long arg2, long arg3, long arg4)
Invokes a function with four numeric arguments, and returns a numeric value.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first numeric argument.arg2
- The second numeric argument.arg3
- The third numeric argument.arg4
- The fourth numeric argument.- Returns:
- A numeric value.
-
invokeN5
static long invokeN5(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5)
Invokes a function with five numeric arguments, and returns a numeric value.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first numeric argument.arg2
- The second numeric argument.arg3
- The third numeric argument.arg4
- The fourth numeric argument.arg5
- The fifth numeric argument.- Returns:
- A numeric value.
-
invokeN6
static long invokeN6(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
Invokes a function with six numeric arguments, and returns a numeric value.- Parameters:
function
- The address of the function context structure fromnewCallContext(long, long[], int)
.arg1
- The first numeric argument.arg2
- The second numeric argument.arg3
- The third numeric argument.arg4
- The fourth numeric argument.arg5
- The fifth numeric argument.arg6
- The sixth numeric argument.- Returns:
- A numeric value.
-
invokeN1O1
static long invokeN1O1(long callContext, long functionAddress, long n1, java.lang.Object o1, int o1flags, int o1off, int o1len)
Invokes a function with one numeric argument, and returns a numeric value.- Parameters:
callContext
- The FFI call context describing the function to invoke.functionAddress
- The native function to invoke.n1
- The first numeric argument.o1
- An Object (array or buffer), to be passed as a pointer.o1flags
- Object flags (direction, type, idx).o1off
- The offset from the start of the array or buffer.o1len
- The length of the array to use.
-
invokeN2O1
static long invokeN2O1(long callContext, long functionAddress, long n1, long n2, java.lang.Object o1, int o1flags, int o1off, int o1len)
Invokes a function with two numeric arguments, and returns a numeric value.- Parameters:
callContext
- The FFI call context describing the function to invoke.functionAddress
- The native function to invoke.n1
- The first numeric argument.n2
- The second numeric argument.o1
- An Object (array or buffer), to be passed as a pointer.o1flags
- Object flags (direction, type, idx).o1off
- The offset from the start of the array or buffer.o1len
- The length of the array to use.- Returns:
- A numeric value.
-
invokeN2O2
static long invokeN2O2(long callContext, long functionAddress, long n1, long n2, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
Invokes a function with two numeric arguments, and returns a numeric value.- Parameters:
callContext
- The FFI call context describing the function to invoke.functionAddress
- The native function to invoke.n1
- The first numeric argument.n2
- The second numeric argument.o1
- An Object (array or buffer), to be passed as a pointer.o1off
- The offset from the start of the array or buffer.o1len
- The length of the array to use.o1flags
- Object flags (direction, type, idx).o2
- An Object (array or buffer), to be passed as a pointer.o2off
- The offset from the start of the array or buffer.o2len
- The length of the array to use.o2flags
- Object flags (direction, type, idx).- Returns:
- A numeric value.
-
invokeN3O1
static long invokeN3O1(long callContext, long functionAddress, long n1, long n2, long n3, java.lang.Object o1, int o1flags, int o1off, int o1len)
Invokes a function with three numeric arguments, and returns a numeric value.- Parameters:
callContext
- The FFI call context describing the function to invoke.functionAddress
- The native function to invoke.n1
- The first numeric argument.n2
- The second numeric argument.n3
- The third numeric argument.o1
- An Object (array or buffer), to be passed as a pointer.o1off
- The offset from the start of the array or buffer.o1len
- The length of the array to use.o1flags
- Object flags (direction, type, parameter index).- Returns:
- A numeric value.
-
invokeN3O2
static long invokeN3O2(long callContext, long functionAddress, long n1, long n2, long n3, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
-
invokeN3O3
static long invokeN3O3(long callContext, long functionAddress, long n1, long n2, long n3, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
-
invokeN4O1
static long invokeN4O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len)
-
invokeN4O2
static long invokeN4O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
-
invokeN4O3
static long invokeN4O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
-
invokeN4O4
static long invokeN4O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len)
-
invokeN5O1
static long invokeN5O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len)
-
invokeN5O2
static long invokeN5O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
-
invokeN5O3
static long invokeN5O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
-
invokeN5O4
static long invokeN5O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len)
-
invokeN5O5
static long invokeN5O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len, java.lang.Object o5, int o5flags, int o5off, int o5len)
-
invokeN6O1
static long invokeN6O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len)
-
invokeN6O2
static long invokeN6O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len)
-
invokeN6O3
static long invokeN6O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len)
-
invokeN6O4
static long invokeN6O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len)
-
invokeN6O5
static long invokeN6O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len, java.lang.Object o5, int o5flags, int o5off, int o5len)
-
invokeN6O6
static long invokeN6O6(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.Object o2, int o2flags, int o2off, int o2len, java.lang.Object o3, int o3flags, int o3off, int o3len, java.lang.Object o4, int o4flags, int o4off, int o4len, java.lang.Object o5, int o5flags, int o5off, int o5len, java.lang.Object o6, int o6flags, int o6off, int o6len)
-
invokeArrayReturnInt
static int invokeArrayReturnInt(long callContext, long function, byte[] buffer)
Invokes a function that returns a 32 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.buffer
- A byte array containing the arguments to the function.- Returns:
- A 32 bit integer value.
-
invokeArrayReturnLong
static long invokeArrayReturnLong(long callContext, long function, byte[] buffer)
Invokes a function that returns a 64 bit integer.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.buffer
- A byte array containing the arguments to the function.- Returns:
- A 64 bit integer value.
-
invokeArrayReturnFloat
static float invokeArrayReturnFloat(long callContext, long function, byte[] buffer)
Invokes a function that returns a 32 bit floating point value.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.buffer
- A byte array containing the arguments to the function.- Returns:
- A 32 bit floating point value.
-
invokeArrayReturnDouble
static double invokeArrayReturnDouble(long callContext, long function, byte[] buffer)
Invokes a function that returns a 64 bit floating point value.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.buffer
- A byte array containing the arguments to the function.- Returns:
- A 64 bit floating point value.
-
invokeArrayReturnStruct
static void invokeArrayReturnStruct(long callContext, long function, byte[] paramBuffer, byte[] returnBuffer, int offset)
Invokes a function and pack the return value into a byte array.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.paramBuffer
- A byte array containing the arguments to the function.
-
invokeArrayWithObjectsReturnObject
static java.lang.Object invokeArrayWithObjectsReturnObject(long callContext, long function, byte[] paramBuffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
Invokes a function that returns a java object. This is only useful when calling JNI functions directly.- Parameters:
callContext
- The address of the call context structure fromnewCallContext(long, long[], int)
.function
- The address of the function to invoke.paramBuffer
- A byte array containing the arguments to the function.
-
invokeArrayWithObjectsInt32
static int invokeArrayWithObjectsInt32(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
-
invokeArrayWithObjectsInt64
static long invokeArrayWithObjectsInt64(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
-
invokeArrayWithObjectsFloat
static float invokeArrayWithObjectsFloat(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
-
invokeArrayWithObjectsDouble
static double invokeArrayWithObjectsDouble(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)
-
invokeArrayWithObjectsReturnStruct
static void invokeArrayWithObjectsReturnStruct(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects, byte[] returnBuffer, int returnBufferOffset)
-
invokeArrayO1Int32
static int invokeArrayO1Int32(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len)
-
invokeArrayO2Int32
static int invokeArrayO2Int32(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len, java.lang.Object o2, int o2info, int o2off, int o2len)
-
invokeArrayO1Int64
static long invokeArrayO1Int64(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len)
-
invokeArrayO2Int64
static long invokeArrayO2Int64(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len, java.lang.Object o2, int o2info, int o2off, int o2len)
-
invokePointerParameterArray
static void invokePointerParameterArray(long callContext, long functionContext, long returnBuffer, long[] parameters)
Invokes a function, with the parameters loaded into native memory buffers, and the function result is stored in a native memory buffer.- Parameters:
functionContext
- The address of the function context structure fromnewCallContext(long, long[], int)
.returnBuffer
- The address of the native buffer to place the result of the function call in.parameters
- An array of addresses of the function parameters.
-
getByte
static byte getByte(long address)
Reads an 8 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A byte containing the value.
-
getShort
static short getShort(long address)
Reads a 16 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A short containing the value.
-
getInt
static int getInt(long address)
Reads a 32 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- An int containing the value.
-
getLong
static long getLong(long address)
Reads a 64 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A long containing the value.
-
getFloat
static float getFloat(long address)
Reads a 32 bit floating point value from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A float containing the value.
-
getDouble
static double getDouble(long address)
Reads a 64 bit floating point value from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A double containing the value.
-
getAddress
static long getAddress(long address)
Reads a native memory address from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A long containing the value.
-
putByte
static void putByte(long address, byte value)
Writes an 8 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putShort
static void putShort(long address, short value)
Writes a 16 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putInt
static void putInt(long address, int value)
Writes a 32 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putLong
static void putLong(long address, long value)
Writes a 64 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putFloat
static void putFloat(long address, float value)
Writes a 32 bit floating point value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putDouble
static void putDouble(long address, double value)
Writes a 64 bit floating point value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putAddress
static void putAddress(long address, long value)
Writes a native memory address value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
setMemory
static void setMemory(long address, long size, byte value)
Sets a region of native memory to a specific byte value.- Parameters:
address
- The address of start of the native memory.size
- The number of bytes to set.value
- The value to set the native memory to.
-
copyMemory
static void copyMemory(long src, long dst, long size)
Copies contents of a native memory location to another native memory location.- Parameters:
src
- The source memory address.dst
- The destination memory address.size
- The number of bytes to copy.
-
putByteArray
static void putByteArray(long address, byte[] data, int offset, int length)
Writes a java byte array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getByteArray
static void getByteArray(long address, byte[] data, int offset, int length)
Reads a java byte array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putCharArray
static void putCharArray(long address, char[] data, int offset, int length)
Writes a java char array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getCharArray
static void getCharArray(long address, char[] data, int offset, int length)
Reads a java char array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putShortArray
static void putShortArray(long address, short[] data, int offset, int length)
Writes a java short array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getShortArray
static void getShortArray(long address, short[] data, int offset, int length)
Reads a java short array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putIntArray
static void putIntArray(long address, int[] data, int offset, int length)
Writes a java int array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getIntArray
static void getIntArray(long address, int[] data, int offset, int length)
Reads a java int array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putLongArray
static void putLongArray(long address, long[] data, int offset, int length)
Writes a java long array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getLongArray
static void getLongArray(long address, long[] data, int offset, int length)
Reads a java long array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putFloatArray
static void putFloatArray(long address, float[] data, int offset, int length)
Writes a java double array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getFloatArray
static void getFloatArray(long address, float[] data, int offset, int length)
Reads a java float array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putDoubleArray
static void putDoubleArray(long address, double[] data, int offset, int length)
Writes a java double array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getDoubleArray
static void getDoubleArray(long address, double[] data, int offset, int length)
Reads a java double array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
memchr
static long memchr(long address, int value, long len)
Gets the address of a byte value in a native memory region.- Parameters:
address
- The native memory address to start searching.value
- The value to search for.len
- The size of the native memory region being searched.- Returns:
- The address of the value, or 0 (zero) if not found.
-
memmove
static void memmove(long dst, long src, long len)
Copies potentially overlapping memory areas.- Parameters:
dst
- The destination memory address.src
- The source memory address.len
- The number of bytes to copy.
-
memcpy
static void memcpy(long dst, long src, long len)
Copies non-overlapping memory areas.- Parameters:
dst
- The destination memory address.src
- The source memory address.len
- The number of bytes to copy.
-
strlen
static long strlen(long address)
Gets the length of a native ascii or utf-8 string.- Parameters:
address
- The native address of the string.- Returns:
- The length of the string, in bytes.
-
getZeroTerminatedByteArray
static byte[] getZeroTerminatedByteArray(long address)
Copies a zero (nul) terminated by array from native memory. This method will search for a zero byte, starting fromaddress
and stop once a zero byte is encountered. The returned byte array does not contain the terminating zero byte.- Parameters:
address
- The address to copy the array from- Returns:
- A byte array containing the bytes copied from native memory.
-
getZeroTerminatedByteArray
static byte[] getZeroTerminatedByteArray(long address, int maxlen)
Copies a zero (nul) terminated by array from native memory. This method will search for a zero byte, starting fromaddress
and stop once a zero byte is encountered. The returned byte array does not contain the terminating zero byte.- Parameters:
address
- The address to copy the array frommaxlen
- The maximum number of bytes to search for the nul terminator- Returns:
- A byte array containing the bytes copied from native memory.
-
putZeroTerminatedByteArray
static void putZeroTerminatedByteArray(long address, byte[] data, int offset, int length)
Copies a java byte array to native memory and appends a NUL terminating byte. Note A total of length + 1 bytes is written to native memory.- Parameters:
address
- The address to copy to.data
- The byte array to copy to native memoryoffset
- The offset within the byte array to begin copying fromlength
- The number of bytes to copy to native memory
-
getByteChecked
static byte getByteChecked(long address)
Reads an 8 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A byte containing the value.
-
getShortChecked
static short getShortChecked(long address)
Reads a 16 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A short containing the value.
-
getIntChecked
static int getIntChecked(long address)
Reads a 32 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- An int containing the value.
-
getLongChecked
static long getLongChecked(long address)
Reads a 64 bit integer from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A long containing the value.
-
getFloatChecked
static float getFloatChecked(long address)
Reads a 32 bit floating point value from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A float containing the value.
-
getDoubleChecked
static double getDoubleChecked(long address)
Reads a 64 bit floating point value from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A double containing the value.
-
getAddressChecked
static long getAddressChecked(long address)
Reads a native memory address from a native memory location.- Parameters:
address
- The memory location to get the value from.- Returns:
- A long containing the value.
-
putByteChecked
static void putByteChecked(long address, byte value)
Writes an 8 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putShortChecked
static void putShortChecked(long address, short value)
Writes a 16 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putIntChecked
static void putIntChecked(long address, int value)
Writes a 32 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putLongChecked
static void putLongChecked(long address, long value)
Writes a 64 bit integer value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putFloatChecked
static void putFloatChecked(long address, float value)
Writes a 32 bit floating point value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putDoubleChecked
static void putDoubleChecked(long address, double value)
Writes a 64 bit floating point value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
putAddressChecked
static void putAddressChecked(long address, long value)
Writes a native memory address value to a native memory location.- Parameters:
address
- The memory location to put the value.value
- The value to write to memory.
-
setMemoryChecked
static void setMemoryChecked(long address, long size, byte value)
Sets a region of native memory to a specific byte value.- Parameters:
address
- The address of start of the native memory.size
- The number of bytes to set.value
- The value to set the native memory to.
-
copyMemoryChecked
static void copyMemoryChecked(long src, long dst, long size)
Copies contents of a native memory location to another native memory location.- Parameters:
src
- The source memory address.dst
- The destination memory address.size
- The number of bytes to copy.
-
putByteArrayChecked
static void putByteArrayChecked(long address, byte[] data, int offset, int length)
Writes a java byte array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getByteArrayChecked
static void getByteArrayChecked(long address, byte[] data, int offset, int length)
Reads a java byte array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putCharArrayChecked
static void putCharArrayChecked(long address, char[] data, int offset, int length)
Writes a java char array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getCharArrayChecked
static void getCharArrayChecked(long address, char[] data, int offset, int length)
Reads a java char array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putShortArrayChecked
static void putShortArrayChecked(long address, short[] data, int offset, int length)
Writes a java short array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getShortArrayChecked
static void getShortArrayChecked(long address, short[] data, int offset, int length)
Reads a java short array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putIntArrayChecked
static void putIntArrayChecked(long address, int[] data, int offset, int length)
Writes a java int array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getIntArrayChecked
static void getIntArrayChecked(long address, int[] data, int offset, int length)
Reads a java int array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putLongArrayChecked
static void putLongArrayChecked(long address, long[] data, int offset, int length)
Writes a java long array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getLongArrayChecked
static void getLongArrayChecked(long address, long[] data, int offset, int length)
Reads a java long array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putFloatArrayChecked
static void putFloatArrayChecked(long address, float[] data, int offset, int length)
Writes a java double array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getFloatArrayChecked
static void getFloatArrayChecked(long address, float[] data, int offset, int length)
Reads a java float array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
putDoubleArrayChecked
static void putDoubleArrayChecked(long address, double[] data, int offset, int length)
Writes a java double array to native memory.- Parameters:
address
- The native memory address to copy the array to.data
- The java array to copy.offset
- The offset within the array to start copying from.length
- The number of array elements to copy.
-
getDoubleArrayChecked
static void getDoubleArrayChecked(long address, double[] data, int offset, int length)
Reads a java double array from native memory.- Parameters:
address
- The native memory address to copy the array from.data
- The java array to copy.offset
- The offset within the array to start copying to.length
- The number of array elements to copy.
-
memchrChecked
static long memchrChecked(long address, int value, long len)
Gets the address of a byte value in a native memory region.- Parameters:
address
- The native memory address to start searching.value
- The value to search for.len
- The size of the native memory region being searched.- Returns:
- The address of the value, or 0 (zero) if not found.
-
memmoveChecked
static void memmoveChecked(long dst, long src, long len)
Copies potentially overlapping memory areas.- Parameters:
dst
- The destination memory address.src
- The source memory address.len
- The number of bytes to copy.
-
memcpyChecked
static void memcpyChecked(long dst, long src, long len)
Copies non-overlapping memory areas.- Parameters:
dst
- The destination memory address.src
- The source memory address.len
- The number of bytes to copy.
-
strlenChecked
static long strlenChecked(long address)
Gets the length of a native ascii or utf-8 string.- Parameters:
address
- The native address of the string.- Returns:
- The length of the string, in bytes.
-
getZeroTerminatedByteArrayChecked
static byte[] getZeroTerminatedByteArrayChecked(long address)
Copies a zero Checked(nul) terminated by array from native memory. This method will search for a zero byte, starting fromaddress
and stop once a zero byte is encountered. The returned byte array does not contain the terminating zero byte.- Parameters:
address
- The address to copy the array from- Returns:
- A byte array containing the bytes copied from native memory.
-
getZeroTerminatedByteArrayChecked
static byte[] getZeroTerminatedByteArrayChecked(long address, int maxlen)
Copies a zero Checked(nul) terminated by array from native memory. This method will search for a zero byte, starting fromaddress
and stop once a zero byte is encountered. The returned byte array does not contain the terminating zero byte.- Parameters:
address
- The address to copy the array frommaxlen
- The maximum number of bytes to search for the nul terminator- Returns:
- A byte array containing the bytes copied from native memory.
-
putZeroTerminatedByteArrayChecked
static void putZeroTerminatedByteArrayChecked(long address, byte[] data, int offset, int length)
Copies a java byte array to native memory and appends a NUL terminating byte. Note A total of length + 1 bytes is written to native memory.- Parameters:
address
- The address to copy to.data
- The byte array to copy to native memoryoffset
- The offset within the byte array to begin copying fromlength
- The number of bytes to copy to native memory
-
newDirectByteBuffer
final java.nio.ByteBuffer newDirectByteBuffer(long address, int capacity)
Creates a new Direct ByteBuffer for a native memory region.- Parameters:
address
- The start of the native memory region.capacity
- The size of the native memory region.- Returns:
- A ByteBuffer representing the native memory region.
-
getDirectBufferAddress
final long getDirectBufferAddress(java.nio.Buffer buffer)
Gets the native memory address of a direct ByteBuffer- Parameters:
buffer
- A direct ByteBuffer to get the address of.- Returns:
- The native memory address of the buffer contents, or null if not a direct buffer.
-
longDoubleFromDouble
final void longDoubleFromDouble(double doubleValue, byte[] buf, int off, int len)
-
longDoubleToDouble
final double longDoubleToDouble(byte[] buf, int off, int len)
-
longDoubleFromString
final void longDoubleFromString(java.lang.String doubleString, byte[] buf, int off, int len)
-
longDoubleToString
final java.lang.String longDoubleToString(byte[] buf, int off, int len)
-
longDoubleToEngineeringString
final java.lang.String longDoubleToEngineeringString(byte[] buf, int off, int len)
-
longDoubleToPlainString
final java.lang.String longDoubleToPlainString(byte[] buf, int off, int len)
-
newNativeMethod
final long newNativeMethod(java.lang.String name, java.lang.String signature, long functionContext)
-
freeNativeMethod
final void freeNativeMethod(long handle)
-
compileNativeMethods
final long compileNativeMethods(long[] methods)
-
freeCompiledMethods
final void freeCompiledMethods(long handle)
-
registerNativeMethods
final boolean registerNativeMethods(java.lang.Class clazz, long handle)
- Parameters:
clazz
- The java class to register the native methods onhandle
- The handle returned from compileNativeMethods- Returns:
- true if successful
-
unregisterNativeMethods
final void unregisterNativeMethods(java.lang.Class clazz)
-
getSaveErrnoFunction
final long getSaveErrnoFunction()
-
setCallContextErrorFunction
final void setCallContextErrorFunction(long ctx, long fn)
-
getSaveErrnoCtxFunction
final long getSaveErrnoCtxFunction()
-
getJNIVersion
final int getJNIVersion()
-
getJavaVM
final long getJavaVM()
-
fatalError
final void fatalError(java.lang.String msg)
-
defineClass
final java.lang.Class defineClass(java.lang.String name, java.lang.Object loader, byte[] buf, int off, int len)
-
defineClass
final java.lang.Class defineClass(java.lang.String name, java.lang.Object loader, java.nio.ByteBuffer buf)
-
allocObject
final java.lang.Object allocObject(java.lang.Class clazz)
-
registerNatives
final int registerNatives(java.lang.Class clazz, long methods, int methodCount)
-
unregisterNatives
final int unregisterNatives(java.lang.Class clazz)
-
getArch
final java.lang.String getArch()
-
-