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 classForeign.InstanceHolderprivate static classForeign.InValidInstanceHolderprivate static classForeign.ValidInstanceHolder
-
Field Summary
Fields Modifier and Type Field Description static intF_DEFAULTDefault calling conventionstatic intF_NOERRNODo not save errno after each callstatic intF_PROTECTTry to capture segmentation faults and convert to java exceptionsstatic intF_STDCALLWindows STDCALL calling conventionstatic intJNI_EDETACHEDstatic intJNI_EEXISTstatic intJNI_EINVALstatic intJNI_ENOMEMstatic intJNI_ERRstatic intJNI_EVERSIONstatic intJNI_OKstatic intMAP_ALIGNstatic intMAP_ANONstatic intMAP_FIXEDUse the specified addressstatic intMAP_NORESERVEstatic intMAP_PRIVATEstatic intMAP_SHAREDShare changesstatic intMAP_TEXTCode segment memorystatic intMEM_4MB_PAGESstatic intMEM_COMMITstatic intMEM_DECOMMITstatic intMEM_FREEstatic intMEM_MAPPEDstatic intMEM_PHYSICALstatic intMEM_PRIVATEstatic intMEM_RELEASEstatic intMEM_RESERVEstatic intMEM_RESETstatic intMEM_TOP_DOWNstatic intPAGE_EXECUTEstatic intPAGE_EXECUTE_READstatic intPAGE_EXECUTE_READWRITEstatic intPAGE_EXECUTE_WRITECOPYstatic intPAGE_NOACCESSWin32 VirtualAlloc/VirtualProtect flagsstatic intPAGE_READONLYstatic intPAGE_READWRITEstatic intPAGE_WRITECOPYstatic intPROT_EXECPages can be executedstatic intPROT_NONEPages cannot be accessedstatic intPROT_READPages can be readstatic intPROT_WRITEPages can be writtenstatic intRTLD_GLOBALAll symbols in the library are made available to other librariesstatic intRTLD_LAZYPerform lazy binding.static intRTLD_LOCALSymbols in this library are not made available to other librariesstatic intRTLD_NOWResolve all symbols when loading the librarystatic intTYPE_DOUBLEstatic intTYPE_FLOATstatic intTYPE_LONGDOUBLEstatic intTYPE_POINTERstatic intTYPE_SCHARstatic intTYPE_SINTstatic intTYPE_SINT16static intTYPE_SINT32static intTYPE_SINT64static intTYPE_SINT8static intTYPE_SLONGstatic intTYPE_SSHORTstatic intTYPE_STRUCTstatic intTYPE_UCHARstatic intTYPE_UINTstatic intTYPE_UINT16static intTYPE_UINT32static intTYPE_UINT64static intTYPE_UINT8static intTYPE_ULONGstatic intTYPE_USHORTstatic intTYPE_VOIDstatic intVERSION_MAJORstatic intVERSION_MICROstatic intVERSION_MINOR
-
Constructor Summary
Constructors Modifier Constructor Description privateForeign()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static longallocateMemory(long size, boolean clear)Allocates native memory.(package private) java.lang.ObjectallocObject(java.lang.Class clazz)(package private) longclosureMagazineGet(long closurePool, java.lang.Object proxy)(package private) 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) java.lang.ClassdefineClass(java.lang.String name, java.lang.Object loader, byte[] buf, int off, int len)(package private) java.lang.ClassdefineClass(java.lang.String name, java.lang.Object loader, java.nio.ByteBuffer buf)(package private) static voiddlclose(long handle)Closes a dynamic library opened bydlopen(java.lang.String, int).(package private) static java.lang.Stringdlerror()Gets the last error raised bydlopen(java.lang.String, int)ordlsym(long, java.lang.String)(package private) static longdlopen(java.lang.String name, int flags)Opens a dynamic library.(package private) static longdlsym(long handle, java.lang.String name)Locates the memory address of a dynamic library symbol.(package private) voidfatalError(java.lang.String msg)(package private) voidfreeAggregate(long handle)Frees a FFI struct, union or array handle allocated vianewStruct(long[], boolean)ornewArray(long, int).(package private) voidfreeCallContext(long callContext)Frees a call context created bynewCallContext(long, long[], int)(package private) voidfreeClosureMagazine(long closurePool)(package private) voidfreeCompiledMethods(long handle)(package private) static voidfreeMemory(long address)Releases memory allocated viaallocateMemory(long, boolean)back to the system.(package private) 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) java.lang.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) 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) longgetDirectBufferAddress(java.nio.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 ForeigngetInstance()(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) longgetJavaVM()(package private) intgetJNIVersion()(package private) static intgetLastError()Gets 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) longgetSaveErrnoCtxFunction()(package private) longgetSaveErrnoFunction()(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) intgetTypeAlign(long handle)Gets the minimum required alignment of the FFI type(package private) intgetTypeSize(long handle)Gets the native size of the type(package private) intgetTypeType(long handle)Gets the primitive type enum for the FFI type(package private) intgetVersion()Gets the native stub library version.private static intgetVersionField(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 voidinit()Initializes any native method/field/class ids(package private) static intinvokeArrayO1Int32(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len)(package private) static longinvokeArrayO1Int64(long callContext, long function, byte[] buffer, java.lang.Object o1, int o1Info, int o1off, int o1len)(package private) static intinvokeArrayO2Int32(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 longinvokeArrayO2Int64(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 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, java.lang.Object[] objects)(package private) static floatinvokeArrayWithObjectsFloat(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)(package private) static intinvokeArrayWithObjectsInt32(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)(package private) static longinvokeArrayWithObjectsInt64(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.Object[] objects)(package private) static java.lang.ObjectinvokeArrayWithObjectsReturnObject(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 voidinvokeArrayWithObjectsReturnStruct(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, java.lang.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, 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 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, 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 longinvokeN2O2(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 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, 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 longinvokeN3O2(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 longinvokeN3O3(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 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, java.lang.Object o1, int o1flags, int o1off, int o1len)(package private) static longinvokeN4O2(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 longinvokeN4O3(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 longinvokeN4O4(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 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, java.lang.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, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.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, 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 longinvokeN5O4(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 longinvokeN5O5(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 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, java.lang.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, java.lang.Object o1, int o1flags, int o1off, int o1len, java.lang.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, 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 longinvokeN6O4(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 longinvokeN6O5(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 longinvokeN6O6(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 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 booleanisFaultProtectionEnabled()(package private) static booleanisMemoryProtectionEnabled()(package private) booleanisRawParameterPackingEnabled()(package private) voidlongDoubleFromDouble(double doubleValue, byte[] buf, int off, int len)(package private) voidlongDoubleFromString(java.lang.String doubleString, byte[] buf, int off, int len)(package private) doublelongDoubleToDouble(byte[] buf, int off, int len)(package private) java.lang.StringlongDoubleToEngineeringString(byte[] buf, int off, int len)(package private) java.lang.StringlongDoubleToPlainString(byte[] buf, int off, int len)(package private) java.lang.StringlongDoubleToString(byte[] buf, int off, int len)(package private) 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) longnewArray(long elementType, int length)Allocates a new FFI array type.(package private) longnewCallContext(long returnType, long[] paramTypes, int flags)Creates a new native call context.(package private) longnewClosureMagazine(long contextAddress, java.lang.reflect.Method closureMethod, boolean callWithPrimitiveParameters)(package private) java.nio.ByteBuffernewDirectByteBuffer(long address, int capacity)Creates a new Direct ByteBuffer for a native memory region.private static java.lang.UnsatisfiedLinkErrornewLoadError(java.lang.Throwable cause)(package private) longnewNativeMethod(java.lang.String name, java.lang.String signature, long functionContext)(package private) 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) booleanregisterNativeMethods(java.lang.Class clazz, long handle)(package private) intregisterNatives(java.lang.Class clazz, long methods, int methodCount)(package private) 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) voidunregisterNativeMethods(java.lang.Class clazz)(package private) intunregisterNatives(java.lang.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 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 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
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()
-
-