Class Foreign
java.lang.Object
com.kenai.jffi.Foreign
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static final classprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault calling conventionstatic final intDo not save errno after each callstatic final intTry to capture segmentation faults and convert to java exceptionsstatic final intWindows STDCALL calling conventionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intUse the specified addressstatic final intstatic final intstatic final intShare changesstatic final intCode segment memorystatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intWin32 VirtualAlloc/VirtualProtect flagsstatic final intstatic final intstatic final intstatic final intPages can be executedstatic final intPages cannot be accessedstatic final intPages can be readstatic final intPages can be writtenstatic final intAll symbols in the library are made available to other librariesstatic final intPerform lazy binding.static final intSymbols in this library are not made available to other librariesstatic final intResolve all symbols when loading the librarystatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static longallocateMemory(long size, boolean clear) Allocates native memory.(package private) final ObjectallocObject(Class clazz) (package private) final longclosureMagazineGet(long closurePool, Object proxy) (package private) final longcompileNativeMethods(long[] methods) (package private) static voidcopyMemory(long src, long dst, long size) Copies contents of a native memory location to another native memory location.(package private) static voidcopyMemoryChecked(long src, long dst, long size) Copies contents of a native memory location to another native memory location.(package private) final ClassdefineClass(String name, Object loader, byte[] buf, int off, int len) (package private) final ClassdefineClass(String name, Object loader, ByteBuffer buf) (package private) static voiddlclose(long handle) Closes a dynamic library opened bydlopen(String, int).(package private) static Stringdlerror()Gets the last error raised bydlopen(String, int)ordlsym(long, String)(package private) static longOpens a dynamic library.(package private) static longLocates the memory address of a dynamic library symbol.(package private) final voidfatalError(String msg) (package private) final voidfreeAggregate(long handle) Frees a FFI struct, union or array handle allocated vianewStruct(long[], boolean)ornewArray(long, int).(package private) final voidfreeCallContext(long callContext) Frees a call context created bynewCallContext(long, long[], int)(package private) final voidfreeClosureMagazine(long closurePool) (package private) final voidfreeCompiledMethods(long handle) (package private) static voidfreeMemory(long address) Releases memory allocated viaallocateMemory(long, boolean)back to the system.(package private) final voidfreeNativeMethod(long handle) (package private) static longgetAddress(long address) Reads a native memory address from a native memory location.(package private) static longgetAddressChecked(long address) Reads a native memory address from a native memory location.(package private) final StringgetArch()(package private) static bytegetByte(long address) Reads an 8 bit integer from a native memory location.(package private) static voidgetByteArray(long address, byte[] data, int offset, int length) Reads a java byte array from native memory.(package private) static voidgetByteArrayChecked(long address, byte[] data, int offset, int length) Reads a java byte array from native memory.(package private) static bytegetByteChecked(long address) Reads an 8 bit integer from a native memory location.(package private) final intgetCallContextRawParameterSize(long callContext) Gets the size required to pack parameters for the function in libffi raw format.(package private) static voidgetCharArray(long address, char[] data, int offset, int length) Reads a java char array from native memory.(package private) static voidgetCharArrayChecked(long address, char[] data, int offset, int length) Reads a java char array from native memory.(package private) final longgetDirectBufferAddress(Buffer buffer) Gets the native memory address of a direct ByteBuffer(package private) static doublegetDouble(long address) Reads a 64 bit floating point value from a native memory location.(package private) static voidgetDoubleArray(long address, double[] data, int offset, int length) Reads a java double array from native memory.(package private) static voidgetDoubleArrayChecked(long address, double[] data, int offset, int length) Reads a java double array from native memory.(package private) static doublegetDoubleChecked(long address) Reads a 64 bit floating point value from a native memory location.(package private) static floatgetFloat(long address) Reads a 32 bit floating point value from a native memory location.(package private) static voidgetFloatArray(long address, float[] data, int offset, int length) Reads a java float array from native memory.(package private) static voidgetFloatArrayChecked(long address, float[] data, int offset, int length) Reads a java float array from native memory.(package private) static floatgetFloatChecked(long address) Reads a 32 bit floating point value from a native memory location.static Foreign(package private) static intgetInt(long address) Reads a 32 bit integer from a native memory location.(package private) static voidgetIntArray(long address, int[] data, int offset, int length) Reads a java int array from native memory.(package private) static voidgetIntArrayChecked(long address, int[] data, int offset, int length) Reads a java int array from native memory.(package private) static intgetIntChecked(long address) Reads a 32 bit integer from a native memory location.(package private) final long(package private) final int(package private) static intGets the last error returned by a native function(package private) static longgetLong(long address) Reads a 64 bit integer from a native memory location.(package private) static voidgetLongArray(long address, long[] data, int offset, int length) Reads a java long array from native memory.(package private) static voidgetLongArrayChecked(long address, long[] data, int offset, int length) Reads a java long array from native memory.(package private) static longgetLongChecked(long address) Reads a 64 bit integer from a native memory location.(package private) final long(package private) final long(package private) static shortgetShort(long address) Reads a 16 bit integer from a native memory location.(package private) static voidgetShortArray(long address, short[] data, int offset, int length) Reads a java short array from native memory.(package private) static voidgetShortArrayChecked(long address, short[] data, int offset, int length) Reads a java short array from native memory.(package private) static shortgetShortChecked(long address) Reads a 16 bit integer from a native memory location.(package private) final intgetTypeAlign(long handle) Gets the minimum required alignment of the FFI type(package private) final intgetTypeSize(long handle) Gets the native size of the type(package private) final intgetTypeType(long handle) Gets the primitive type enum for the FFI type(package private) final intGets the native stub library version.private static intgetVersionField(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 voidinit()Initializes any native method/field/class ids(package private) static intinvokeArrayO1Int32(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len) (package private) static longinvokeArrayO1Int64(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len) (package private) static intinvokeArrayO2Int32(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len, Object o2, int o2info, int o2off, int o2len) (package private) static longinvokeArrayO2Int64(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len, Object o2, int o2info, int o2off, int o2len) (package private) static doubleinvokeArrayReturnDouble(long callContext, long function, byte[] buffer) Invokes a function that returns a 64 bit floating point value.(package private) static floatinvokeArrayReturnFloat(long callContext, long function, byte[] buffer) Invokes a function that returns a 32 bit floating point value.(package private) static intinvokeArrayReturnInt(long callContext, long function, byte[] buffer) Invokes a function that returns a 32 bit integer.(package private) static longinvokeArrayReturnLong(long callContext, long function, byte[] buffer) Invokes a function that returns a 64 bit integer.(package private) static voidinvokeArrayReturnStruct(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 doubleinvokeArrayWithObjectsDouble(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects) (package private) static floatinvokeArrayWithObjectsFloat(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects) (package private) static intinvokeArrayWithObjectsInt32(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects) (package private) static longinvokeArrayWithObjectsInt64(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects) (package private) static ObjectinvokeArrayWithObjectsReturnObject(long callContext, long function, byte[] paramBuffer, int objectCount, int[] objectInfo, Object[] objects) Invokes a function that returns a java object.(package private) static voidinvokeArrayWithObjectsReturnStruct(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects, byte[] returnBuffer, int returnBufferOffset) (package private) static intinvokeI0(long callContext, long function) Invokes a function with no arguments, and returns a 32 bit integer.(package private) static intinvokeI0NoErrno(long callContext, long function) Invokes a function with no arguments, and returns a 32 bit integer.(package private) static intinvokeI1(long callContext, long function, int arg1) Invokes a function with one integer argument, and returns a 32 bit integer.(package private) static intinvokeI1NoErrno(long callContext, long function, int arg1) Invokes a function with one integer argument, and returns a 32 bit integer.(package private) static intinvokeI2(long callContext, long function, int arg1, int arg2) Invokes a function with two integer arguments, and returns a 32 bit integer.(package private) static intinvokeI2NoErrno(long callContext, long function, int arg1, int arg2) Invokes a function with two integer arguments, and returns a 32 bit integer.(package private) static intinvokeI3(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 intinvokeI3NoErrno(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 intinvokeI4(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 intinvokeI4NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4) (package private) static intinvokeI5(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 intinvokeI5NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5) (package private) static intinvokeI6(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 intinvokeI6NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) (package private) static longinvokeL0(long ctx, long function) Invokes a function with no arguments, and returns a 64 bit integer.(package private) static longinvokeL0NoErrno(long ctx, long function) (package private) static longinvokeL1(long ctx, long function, long arg1) Invokes a function with one 64 bit integer argument, and returns a 64 bit integer.(package private) static longinvokeL1NoErrno(long ctx, long function, long arg1) (package private) static longinvokeL2(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 longinvokeL2NoErrno(long ctx, long function, long arg1, long arg2) (package private) static longinvokeL3(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 longinvokeL3NoErrno(long ctx, long function, long arg1, long arg2, long arg3) (package private) static longinvokeL4(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 longinvokeL4NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4) (package private) static longinvokeL5(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 longinvokeL5NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5) (package private) static longinvokeL6(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 longinvokeL6NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) (package private) static longinvokeN0(long ctx, long function) Invokes a function with zero numeric arguments, and returns a numeric value.(package private) static longinvokeN1(long ctx, long function, long arg1) Invokes a function with one numeric arguments, and returns a numeric value.(package private) static longinvokeN1O1(long callContext, long functionAddress, long n1, Object o1, int o1flags, int o1off, int o1len) Invokes a function with one numeric argument, and returns a numeric value.(package private) static longinvokeN2(long ctx, long function, long arg1, long arg2) Invokes a function with two numeric arguments, and returns a numeric value.(package private) static longinvokeN2O1(long callContext, long functionAddress, long n1, long n2, Object o1, int o1flags, int o1off, int o1len) Invokes a function with two numeric arguments, and returns a numeric value.(package private) static longinvokeN2O2(long callContext, long functionAddress, long n1, long n2, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len) Invokes a function with two numeric arguments, and returns a numeric value.(package private) static longinvokeN3(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 longinvokeN3O1(long callContext, long functionAddress, long n1, long n2, long n3, Object o1, int o1flags, int o1off, int o1len) Invokes a function with three numeric arguments, and returns a numeric value.(package private) static longinvokeN3O2(long callContext, long functionAddress, long n1, long n2, long n3, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len) (package private) static longinvokeN3O3(long callContext, long functionAddress, long n1, long n2, long n3, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len) (package private) static longinvokeN4(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 longinvokeN4O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len) (package private) static longinvokeN4O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len) (package private) static longinvokeN4O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len) (package private) static longinvokeN4O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len) (package private) static longinvokeN5(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 longinvokeN5O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len) (package private) static longinvokeN5O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len) (package private) static longinvokeN5O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len) (package private) static longinvokeN5O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len) (package private) static longinvokeN5O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, Object o5, int o5flags, int o5off, int o5len) (package private) static longinvokeN6(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 longinvokeN6O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len) (package private) static longinvokeN6O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len) (package private) static longinvokeN6O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len) (package private) static longinvokeN6O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len) (package private) static longinvokeN6O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, Object o5, int o5flags, int o5off, int o5len) (package private) static longinvokeN6O6(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, Object o5, int o5flags, int o5off, int o5len, Object o6, int o6flags, int o6off, int o6len) (package private) static voidinvokePointerParameterArray(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(package private) static boolean(package private) final boolean(package private) final voidlongDoubleFromDouble(double doubleValue, byte[] buf, int off, int len) (package private) final voidlongDoubleFromString(String doubleString, byte[] buf, int off, int len) (package private) final doublelongDoubleToDouble(byte[] buf, int off, int len) (package private) final StringlongDoubleToEngineeringString(byte[] buf, int off, int len) (package private) final StringlongDoubleToPlainString(byte[] buf, int off, int len) (package private) final StringlongDoubleToString(byte[] buf, int off, int len) (package private) final longlookupBuiltinType(int type) Gets the address of the ffi_type structure for the builtin type(package private) static longmemchr(long address, int value, long len) Gets the address of a byte value in a native memory region.(package private) static longmemchrChecked(long address, int value, long len) Gets the address of a byte value in a native memory region.(package private) static voidmemcpy(long dst, long src, long len) Copies non-overlapping memory areas.(package private) static voidmemcpyChecked(long dst, long src, long len) Copies non-overlapping memory areas.(package private) static voidmemmove(long dst, long src, long len) Copies potentially overlapping memory areas.(package private) static voidmemmoveChecked(long dst, long src, long len) Copies potentially overlapping memory areas.(package private) static longmmap(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 intmprotect(long addr, long len, int prot) Calls the Unix mprotect(2) function.(package private) static intmunmap(long addr, long len) Calls the Unix munmap(2) function.(package private) final longnewArray(long elementType, int length) Allocates a new FFI array type.(package private) final longnewCallContext(long returnType, long[] paramTypes, int flags) Creates a new native call context.(package private) final longnewClosureMagazine(long contextAddress, Method closureMethod, boolean callWithPrimitiveParameters) (package private) final ByteBuffernewDirectByteBuffer(long address, int capacity) Creates a new Direct ByteBuffer for a native memory region.private static UnsatisfiedLinkErrornewLoadError(Throwable cause) (package private) final longnewNativeMethod(String name, String signature, long functionContext) (package private) final longnewStruct(long[] fields, boolean isUnion) Allocates a new FFI struct or union layout(package private) static longpageSize()Gets the size of a page of memory.(package private) static voidputAddress(long address, long value) Writes a native memory address value to a native memory location.(package private) static voidputAddressChecked(long address, long value) Writes a native memory address value to a native memory location.(package private) static voidputByte(long address, byte value) Writes an 8 bit integer value to a native memory location.(package private) static voidputByteArray(long address, byte[] data, int offset, int length) Writes a java byte array to native memory.(package private) static voidputByteArrayChecked(long address, byte[] data, int offset, int length) Writes a java byte array to native memory.(package private) static voidputByteChecked(long address, byte value) Writes an 8 bit integer value to a native memory location.(package private) static voidputCharArray(long address, char[] data, int offset, int length) Writes a java char array to native memory.(package private) static voidputCharArrayChecked(long address, char[] data, int offset, int length) Writes a java char array to native memory.(package private) static voidputDouble(long address, double value) Writes a 64 bit floating point value to a native memory location.(package private) static voidputDoubleArray(long address, double[] data, int offset, int length) Writes a java double array to native memory.(package private) static voidputDoubleArrayChecked(long address, double[] data, int offset, int length) Writes a java double array to native memory.(package private) static voidputDoubleChecked(long address, double value) Writes a 64 bit floating point value to a native memory location.(package private) static voidputFloat(long address, float value) Writes a 32 bit floating point value to a native memory location.(package private) static voidputFloatArray(long address, float[] data, int offset, int length) Writes a java double array to native memory.(package private) static voidputFloatArrayChecked(long address, float[] data, int offset, int length) Writes a java double array to native memory.(package private) static voidputFloatChecked(long address, float value) Writes a 32 bit floating point value to a native memory location.(package private) static voidputInt(long address, int value) Writes a 32 bit integer value to a native memory location.(package private) static voidputIntArray(long address, int[] data, int offset, int length) Writes a java int array to native memory.(package private) static voidputIntArrayChecked(long address, int[] data, int offset, int length) Writes a java int array to native memory.(package private) static voidputIntChecked(long address, int value) Writes a 32 bit integer value to a native memory location.(package private) static voidputLong(long address, long value) Writes a 64 bit integer value to a native memory location.(package private) static voidputLongArray(long address, long[] data, int offset, int length) Writes a java long array to native memory.(package private) static voidputLongArrayChecked(long address, long[] data, int offset, int length) Writes a java long array to native memory.(package private) static voidputLongChecked(long address, long value) Writes a 64 bit integer value to a native memory location.(package private) static voidputShort(long address, short value) Writes a 16 bit integer value to a native memory location.(package private) static voidputShortArray(long address, short[] data, int offset, int length) Writes a java short array to native memory.(package private) static voidputShortArrayChecked(long address, short[] data, int offset, int length) Writes a java short array to native memory.(package private) static voidputShortChecked(long address, short value) Writes a 16 bit integer value to a native memory location.(package private) static voidputZeroTerminatedByteArray(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 voidputZeroTerminatedByteArrayChecked(long address, byte[] data, int offset, int length) Copies a java byte array to native memory and appends a NUL terminating byte.(package private) final booleanregisterNativeMethods(Class clazz, long handle) (package private) final intregisterNatives(Class clazz, long methods, int methodCount) (package private) final voidsetCallContextErrorFunction(long ctx, long fn) (package private) static voidsetLastError(int error) Sets the native errno value(package private) static voidsetMemory(long address, long size, byte value) Sets a region of native memory to a specific byte value.(package private) static voidsetMemoryChecked(long address, long size, byte value) Sets a region of native memory to a specific byte value.(package private) static longstrlen(long address) Gets the length of a native ascii or utf-8 string.(package private) static longstrlenChecked(long address) Gets the length of a native ascii or utf-8 string.(package private) final voidunregisterNativeMethods(Class clazz) (package private) final intunregisterNatives(Class clazz) (package private) static longVirtualAlloc(long addr, int size, int flags, int prot) (package private) static booleanVirtualFree(long addr, int size, int flags) (package private) static booleanVirtualProtect(long addr, int size, int prot)
-
Field Details
-
VERSION_MAJOR
-
VERSION_MINOR
-
VERSION_MICRO
-
TYPE_VOID
- See Also:
-
TYPE_FLOAT
- See Also:
-
TYPE_DOUBLE
- See Also:
-
TYPE_LONGDOUBLE
- See Also:
-
TYPE_UINT8
- See Also:
-
TYPE_SINT8
- See Also:
-
TYPE_UINT16
- See Also:
-
TYPE_SINT16
- See Also:
-
TYPE_UINT32
- See Also:
-
TYPE_SINT32
- See Also:
-
TYPE_UINT64
- See Also:
-
TYPE_SINT64
- See Also:
-
TYPE_STRUCT
- See Also:
-
TYPE_POINTER
- See Also:
-
TYPE_UCHAR
- See Also:
-
TYPE_SCHAR
- See Also:
-
TYPE_USHORT
- See Also:
-
TYPE_SSHORT
- See Also:
-
TYPE_UINT
- See Also:
-
TYPE_SINT
- See Also:
-
TYPE_ULONG
- See Also:
-
TYPE_SLONG
- See Also:
-
RTLD_LAZY
Perform lazy binding. Only resolve symbols as needed- See Also:
-
RTLD_NOW
-
RTLD_LOCAL
Symbols in this library are not made available to other libraries- See Also:
-
RTLD_GLOBAL
All symbols in the library are made available to other libraries- See Also:
-
PROT_READ
-
PROT_WRITE
-
PROT_EXEC
-
PROT_NONE
-
MAP_SHARED
-
MAP_PRIVATE
- See Also:
-
MAP_FIXED
-
MAP_NORESERVE
- See Also:
-
MAP_ANON
- See Also:
-
MAP_ALIGN
- See Also:
-
MAP_TEXT
-
PAGE_NOACCESS
-
PAGE_READONLY
- See Also:
-
PAGE_READWRITE
- See Also:
-
PAGE_WRITECOPY
- See Also:
-
PAGE_EXECUTE
- See Also:
-
PAGE_EXECUTE_READ
- See Also:
-
PAGE_EXECUTE_READWRITE
- See Also:
-
PAGE_EXECUTE_WRITECOPY
- See Also:
-
MEM_COMMIT
- See Also:
-
MEM_RESERVE
- See Also:
-
MEM_DECOMMIT
- See Also:
-
MEM_RELEASE
- See Also:
-
MEM_FREE
- See Also:
-
MEM_PRIVATE
- See Also:
-
MEM_MAPPED
- See Also:
-
MEM_RESET
- See Also:
-
MEM_TOP_DOWN
- See Also:
-
MEM_PHYSICAL
- See Also:
-
MEM_4MB_PAGES
- See Also:
-
JNI_OK
public static final int JNI_OK- See Also:
-
JNI_ERR
public static final int JNI_ERR- See Also:
-
JNI_EDETACHED
public static final int JNI_EDETACHED- See Also:
-
JNI_EVERSION
public static final int JNI_EVERSION- See Also:
-
JNI_ENOMEM
public static final int JNI_ENOMEM- See Also:
-
JNI_EEXIST
public static final int JNI_EEXIST- See Also:
-
JNI_EINVAL
public static final int JNI_EINVAL- See Also:
-
F_DEFAULT
-
F_STDCALL
-
F_NOERRNO
-
F_PROTECT
Try to capture segmentation faults and convert to java exceptions- See Also:
-
-
Constructor Details
-
Foreign
private Foreign()
-
-
Method Details
-
newLoadError
-
getInstance
-
getVersionField
-
getVersion
final int getVersion()Gets the native stub library version.- Returns:
- The version in the form of (VERSION_MAJOR invalid input: '<'invalid input: '<' 16 | VERSION_MINOR invalid input: '<'invalid input: '<' 8 | VERSION_MICRO)
-
init
private void init()Initializes any native method/field/class ids -
isFaultProtectionEnabled
private static boolean isFaultProtectionEnabled() -
isMemoryProtectionEnabled
static boolean isMemoryProtectionEnabled() -
dlopen
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(String, int).- Parameters:
handle- The dynamic library handle returned bydlopen(String, int)
-
dlsym
Locates the memory address of a dynamic library symbol.- Parameters:
handle- A dynamic library handle obtained fromdlopen(String, int)name- The name of the symbol.- Returns:
- The address where the symbol in loaded in memory.
-
dlerror
Gets the last error raised bydlopen(String, int)ordlsym(long, 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, Method closureMethod, boolean callWithPrimitiveParameters) -
freeClosureMagazine
final void freeClosureMagazine(long closurePool) -
closureMagazineGet
-
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:
-
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
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, 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, 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, Object o1, int o1flags, int o1off, int o1len, 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.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.o2- An Object (array or buffer), to be passed as a pointer.o2flags- Object flags (direction, type, idx).o2off- The offset from the start of the array or buffer.o2len- The length of the array to use.- Returns:
- A numeric value.
-
invokeN3O1
static long invokeN3O1(long callContext, long functionAddress, long n1, long n2, long n3, 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.o1flags- Object flags (direction, type, parameter index).o1off- The offset from the start of the array or buffer.o1len- The length of the array to use.- Returns:
- A numeric value.
-
invokeN3O2
-
invokeN3O3
-
invokeN4O1
static long invokeN4O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len) -
invokeN4O2
-
invokeN4O3
-
invokeN4O4
-
invokeN5O1
static long invokeN5O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len) -
invokeN5O2
-
invokeN5O3
-
invokeN5O4
-
invokeN5O5
static long invokeN5O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, 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, Object o1, int o1flags, int o1off, int o1len) -
invokeN6O2
-
invokeN6O3
-
invokeN6O4
static long invokeN6O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, 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, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, 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, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, Object o5, int o5flags, int o5off, int o5len, 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 Object invokeArrayWithObjectsReturnObject(long callContext, long function, byte[] paramBuffer, int objectCount, int[] objectInfo, 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, Object[] objects) -
invokeArrayWithObjectsInt64
static long invokeArrayWithObjectsInt64(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects) -
invokeArrayWithObjectsFloat
static float invokeArrayWithObjectsFloat(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects) -
invokeArrayWithObjectsDouble
static double invokeArrayWithObjectsDouble(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects) -
invokeArrayWithObjectsReturnStruct
static void invokeArrayWithObjectsReturnStruct(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects, byte[] returnBuffer, int returnBufferOffset) -
invokeArrayO1Int32
static int invokeArrayO1Int32(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len) -
invokeArrayO2Int32
-
invokeArrayO1Int64
static long invokeArrayO1Int64(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len) -
invokeArrayO2Int64
-
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 fromaddressand 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 fromaddressand 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 fromaddressand 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 fromaddressand 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
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
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
-
longDoubleToString
-
longDoubleToEngineeringString
-
longDoubleToPlainString
-
newNativeMethod
-
freeNativeMethod
final void freeNativeMethod(long handle) -
compileNativeMethods
final long compileNativeMethods(long[] methods) -
freeCompiledMethods
final void freeCompiledMethods(long handle) -
registerNativeMethods
- Parameters:
clazz- The java class to register the native methods onhandle- The handle returned from compileNativeMethods- Returns:
- true if successful
-
unregisterNativeMethods
-
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
-
defineClass
-
defineClass
-
allocObject
-
registerNatives
-
unregisterNatives
-
getArch
-