Top Inners Fields Constructors Methods
com.kenai.jffi

pack-priv final Class Foreign

extends Object
Class Inheritance
Imports
java.lang.annotation.Native, java.lang.reflect.Method, java.nio.Buffer, .ByteBuffer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
public static final int
F_DEFAULT

Default calling convention

public static final int
F_NOERRNO

Do not save errno after each call

public static final int
F_PROTECT

Try to capture segmentation faults and convert to java exceptions

public static final int
F_STDCALL

Windows STDCALL calling convention

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
MAP_FIXED

Use the specified address

public static final int
public static final int
public static final int
MAP_SHARED

Share changes

public static final int
MAP_TEXT

Code segment memory

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
PAGE_NOACCESS

Win32 VirtualAlloc/VirtualProtect flags

public static final int
public static final int
public static final int
public static final int
PROT_EXEC

Pages can be executed

public static final int
PROT_NONE

Pages cannot be accessed

public static final int
PROT_READ

Pages can be read

public static final int
PROT_WRITE

Pages can be written

public static final int
RTLD_GLOBAL

All symbols in the library are made available to other libraries

public static final int
RTLD_LAZY

Perform lazy binding.

public static final int
RTLD_LOCAL

Symbols in this library are not made available to other libraries

public static final int
RTLD_NOW

Resolve all symbols when loading the library

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static native long

Returns:

The native address of the allocated memory.
allocateMemory
(long
The number of bytes of memory to allocate
size
,
boolean
Whether the memory should be cleared (each byte set to zero).
clear
)

Allocates native memory.

pack-priv final native Object
allocObject(Class<T> clazz)

pack-priv final native long
closureMagazineGet(long closurePool, Object proxy)

pack-priv final native long
compileNativeMethods(long[] methods)

pack-priv static native void
copyMemory(long
The source memory address.
src
,
long
The destination memory address.
dst
,
long
The number of bytes to copy.
size
)

Copies contents of a native memory location to another native memory location.

pack-priv static native void
copyMemoryChecked(long
The source memory address.
src
,
long
The destination memory address.
dst
,
long
The number of bytes to copy.
size
)

Copies contents of a native memory location to another native memory location.

pack-priv final native Class<T>
defineClass(String name, Object loader, byte[] buf, int off, int len)

pack-priv final native Class<T>
defineClass(String name, Object loader, ByteBuffer buf)

pack-priv static native void
dlclose(long
The dynamic library handle returned by dlopen
handle
)

Closes a dynamic library opened by dlopen.

pack-priv static native String

Returns:

The error string.
dlerror
()

Gets the last error raised by dlopen or dlsym

pack-priv static native long

Returns:

A native handle to the dynamic library.
dlopen
(String
The name of the dynamic library to open. Pass null to get a handle to the current process.
name
,
int
The flags to dlopen. A bit mask of RTLD_LAZY, RTLD_NOW, RTLD_LOCAL, RTLD_GLOBAL
flags
)

Opens a dynamic library.

pack-priv static native long

Returns:

The address where the symbol in loaded in memory.
dlsym
(long
A dynamic library handle obtained from dlopen
handle
,
String
The name of the symbol.
name
)

Locates the memory address of a dynamic library symbol.

pack-priv final native void
pack-priv final native void
freeAggregate(long
The FFI struct handle
handle
)

Frees a FFI struct, union or array handle allocated via newStruct or newArray.

pack-priv final native void
freeCallContext(long
The native call context to free
callContext
)

Frees a call context created by newCallContext

pack-priv final native void
freeClosureMagazine(long closurePool)

pack-priv final native void
freeCompiledMethods(long handle)

pack-priv static native void
freeMemory(long
The address of the memory to release.
address
)

Releases memory allocated via allocateMemory back to the system.

pack-priv final native void
freeNativeMethod(long handle)

pack-priv static native long

Returns:

A long containing the value.
getAddress
(long
The memory location to get the value from.
address
)

Reads a native memory address from a native memory location.

pack-priv static native long

Returns:

A long containing the value.
getAddressChecked
(long
The memory location to get the value from.
address
)

Reads a native memory address from a native memory location.

pack-priv final native String
pack-priv static native byte

Returns:

A byte containing the value.
getByte
(long
The memory location to get the value from.
address
)

Reads an 8 bit integer from a native memory location.

pack-priv static native void
getByteArray(long
The native memory address to copy the array from.
address
,
byte[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java byte array from native memory.

pack-priv static native void
getByteArrayChecked(long
The native memory address to copy the array from.
address
,
byte[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java byte array from native memory.

pack-priv static native byte

Returns:

A byte containing the value.
getByteChecked
(long
The memory location to get the value from.
address
)

Reads an 8 bit integer from a native memory location.

pack-priv final native int

Returns:

The size in bytes required to pack parameters in raw format
getCallContextRawParameterSize
(long
The call context
callContext
)

Gets the size required to pack parameters for the function in libffi raw format.

pack-priv static native void
getCharArray(long
The native memory address to copy the array from.
address
,
char[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java char array from native memory.

pack-priv static native void
getCharArrayChecked(long
The native memory address to copy the array from.
address
,
char[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java char array from native memory.

pack-priv final native long

Returns:

The native memory address of the buffer contents, or null if not a direct buffer.
getDirectBufferAddress
(Buffer
A direct ByteBuffer to get the address of.
buffer
)

Gets the native memory address of a direct ByteBuffer

pack-priv static native double

Returns:

A double containing the value.
getDouble
(long
The memory location to get the value from.
address
)

Reads a 64 bit floating point value from a native memory location.

pack-priv static native void
getDoubleArray(long
The native memory address to copy the array from.
address
,
double[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java double array from native memory.

pack-priv static native void
getDoubleArrayChecked(long
The native memory address to copy the array from.
address
,
double[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java double array from native memory.

pack-priv static native double

Returns:

A double containing the value.
getDoubleChecked
(long
The memory location to get the value from.
address
)

Reads a 64 bit floating point value from a native memory location.

pack-priv static native float

Returns:

A float containing the value.
getFloat
(long
The memory location to get the value from.
address
)

Reads a 32 bit floating point value from a native memory location.

pack-priv static native void
getFloatArray(long
The native memory address to copy the array from.
address
,
float[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java float array from native memory.

pack-priv static native void
getFloatArrayChecked(long
The native memory address to copy the array from.
address
,
float[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java float array from native memory.

pack-priv static native float

Returns:

A float containing the value.
getFloatChecked
(long
The memory location to get the value from.
address
)

Reads a 32 bit floating point value from a native memory location.

public static Foreign
pack-priv static native int

Returns:

An int containing the value.
getInt
(long
The memory location to get the value from.
address
)

Reads a 32 bit integer from a native memory location.

pack-priv static native void
getIntArray(long
The native memory address to copy the array from.
address
,
int[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java int array from native memory.

pack-priv static native void
getIntArrayChecked(long
The native memory address to copy the array from.
address
,
int[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java int array from native memory.

pack-priv static native int

Returns:

An int containing the value.
getIntChecked
(long
The memory location to get the value from.
address
)

Reads a 32 bit integer from a native memory location.

pack-priv final native long
pack-priv final native int
pack-priv static native int

Returns:

An integer.
getLastError
()

Gets the last error returned by a native function

pack-priv static native long

Returns:

A long containing the value.
getLong
(long
The memory location to get the value from.
address
)

Reads a 64 bit integer from a native memory location.

pack-priv static native void
getLongArray(long
The native memory address to copy the array from.
address
,
long[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java long array from native memory.

pack-priv static native void
getLongArrayChecked(long
The native memory address to copy the array from.
address
,
long[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java long array from native memory.

pack-priv static native long

Returns:

A long containing the value.
getLongChecked
(long
The memory location to get the value from.
address
)

Reads a 64 bit integer from a native memory location.

pack-priv final native long
pack-priv final native long
pack-priv static native short

Returns:

A short containing the value.
getShort
(long
The memory location to get the value from.
address
)

Reads a 16 bit integer from a native memory location.

pack-priv static native void
getShortArray(long
The native memory address to copy the array from.
address
,
short[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java short array from native memory.

pack-priv static native void
getShortArrayChecked(long
The native memory address to copy the array from.
address
,
short[]
The java array to copy.
data
,
int
The offset within the array to start copying to.
offset
,
int
The number of array elements to copy.
length
)

Reads a java short array from native memory.

pack-priv static native short

Returns:

A short containing the value.
getShortChecked
(long
The memory location to get the value from.
address
)

Reads a 16 bit integer from a native memory location.

pack-priv final native int

Returns:

The minimum required alignment
getTypeAlign
(long
Address of the type structure
handle
)

Gets the minimum required alignment of the FFI type

pack-priv final native int

Returns:

The native size of the type
getTypeSize
(long
Address of the type structure
handle
)

Gets the native size of the type

pack-priv final native int

Returns:

The builtin primitive type of the type structure
getTypeType
(long
Address of the type structure
handle
)

Gets the primitive type enum for the FFI type

pack-priv final native int

Returns:

The version in the form of (VERSION_MAJOR << 16 | VERSION_MINOR << 8 | VERSION_MICRO)
getVersion
()

Gets the native stub library version.

private static int
pack-priv static native byte[]

Returns:

A byte array containing the bytes copied from native memory.
getZeroTerminatedByteArray
(long
The address to copy the array from
address
)

Copies a zero (nul) terminated by array from native memory.

pack-priv static native byte[]

Returns:

A byte array containing the bytes copied from native memory.
getZeroTerminatedByteArray
(long
The address to copy the array from
address
,
int
The maximum number of bytes to search for the nul terminator
maxlen
)

Copies a zero (nul) terminated by array from native memory.

pack-priv static native byte[]

Returns:

A byte array containing the bytes copied from native memory.
getZeroTerminatedByteArrayChecked
(long
The address to copy the array from
address
)

Copies a zero Checked(nul) terminated by array from native memory.

pack-priv static native byte[]

Returns:

A byte array containing the bytes copied from native memory.
getZeroTerminatedByteArrayChecked
(long
The address to copy the array from
address
,
int
The maximum number of bytes to search for the nul terminator
maxlen
)

Copies a zero Checked(nul) terminated by array from native memory.

private native void
init()

Initializes any native method/field/class ids

pack-priv static native int
invokeArrayO1Int32(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len)

pack-priv static native long
invokeArrayO1Int64(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len)

pack-priv static native int
invokeArrayO2Int32(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len, Object o2, int o2info, int o2off, int o2len)

pack-priv static native long
invokeArrayO2Int64(long callContext, long function, byte[] buffer, Object o1, int o1Info, int o1off, int o1len, Object o2, int o2info, int o2off, int o2len)

pack-priv static native double

Returns:

A 64 bit floating point value.
invokeArrayReturnDouble
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
byte[]
A byte array containing the arguments to the function.
buffer
)

Invokes a function that returns a 64 bit floating point value.

pack-priv static native float

Returns:

A 32 bit floating point value.
invokeArrayReturnFloat
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
byte[]
A byte array containing the arguments to the function.
buffer
)

Invokes a function that returns a 32 bit floating point value.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeArrayReturnInt
(long
The address of the call context structure from newCallContext.
callContext
,
long function, byte[]
A byte array containing the arguments to the function.
buffer
)

Invokes a function that returns a 32 bit integer.

pack-priv static native long

Returns:

A 64 bit integer value.
invokeArrayReturnLong
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
byte[]
A byte array containing the arguments to the function.
buffer
)

Invokes a function that returns a 64 bit integer.

pack-priv static native void
invokeArrayReturnStruct(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
byte[]
A byte array containing the arguments to the function.
paramBuffer
,
byte[] returnBuffer, int offset)

Invokes a function and pack the return value into a byte array.

pack-priv static native double
invokeArrayWithObjectsDouble(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects)

pack-priv static native float
invokeArrayWithObjectsFloat(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects)

pack-priv static native int
invokeArrayWithObjectsInt32(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects)

pack-priv static native long
invokeArrayWithObjectsInt64(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects)

pack-priv static native Object
invokeArrayWithObjectsReturnObject(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
byte[]
A byte array containing the arguments to the function.
paramBuffer
,
int objectCount, int[] objectInfo, Object[] objects)

Invokes a function that returns a java object.

pack-priv static native void
invokeArrayWithObjectsReturnStruct(long callContext, long function, byte[] buffer, int objectCount, int[] objectInfo, Object[] objects, byte[] returnBuffer, int returnBufferOffset)

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI0
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
)

Invokes a function with no arguments, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI0NoErrno
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
)

Invokes a function with no arguments, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI1
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The 32 bit integer argument.
arg1
)

Invokes a function with one integer argument, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI1NoErrno
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The 32 bit integer argument.
arg1
)

Invokes a function with one integer argument, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI2
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The first 32 bit integer argument.
arg1
,
int
The second 32 bit integer argument.
arg2
)

Invokes a function with two integer arguments, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI2NoErrno
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The first 32 bit integer argument.
arg1
,
int
The second 32 bit integer argument.
arg2
)

Invokes a function with two integer arguments, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI3
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The first 32 bit integer argument.
arg1
,
int
The second 32 bit integer argument.
arg2
,
int
The third 32 bit integer argument.
arg3
)

Invokes a function with three integer arguments, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI3NoErrno
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The first 32 bit integer argument.
arg1
,
int
The second 32 bit integer argument.
arg2
,
int
The third 32 bit integer argument.
arg3
)

Invokes a function with three integer arguments, and returns a 32 bit integer.

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI4
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The first 32 bit integer argument.
arg1
,
int
The second 32 bit integer argument.
arg2
,
int
The third 32 bit integer argument.
arg3
,
int
The third 32 bit integer argument.
arg4
)

Invokes a function with four integer arguments, and returns a 32 bit integer.

pack-priv static native int
invokeI4NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4)

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI5
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The first 32 bit integer argument.
arg1
,
int
The second 32 bit integer argument.
arg2
,
int
The third 32 bit integer argument.
arg3
,
int
The fourth 32 bit integer argument.
arg4
,
int
The fifth 32 bit integer argument.
arg5
)

Invokes a function with five integer arguments, and returns a 32 bit integer.

pack-priv static native int
invokeI5NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5)

pack-priv static native int

Returns:

A 32 bit integer value.
invokeI6
(long
The address of the call context structure from newCallContext.
callContext
,
long
The address of the function to invoke.
function
,
int
The first 32 bit integer argument.
arg1
,
int
The second 32 bit integer argument.
arg2
,
int
The third 32 bit integer argument.
arg3
,
int
The fourth 32 bit integer argument.
arg4
,
int
The fifth 32 bit integer argument.
arg5
,
int
The sixth 32 bit integer argument.
arg6
)

Invokes a function with six integer arguments, and returns a 32 bit integer.

pack-priv static native int
invokeI6NoErrno(long callContext, long function, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)

pack-priv static native long

Returns:

A 64 bit integer value.
invokeL0
(long ctx, long
The address of the function context structure from newCallContext.
function
)

Invokes a function with no arguments, and returns a 64 bit integer.

pack-priv static native long
invokeL0NoErrno(long ctx, long function)

pack-priv static native long

Returns:

A 64 bit integer value.
invokeL1
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The 64 bit integer argument.
arg1
)

Invokes a function with one 64 bit integer argument, and returns a 64 bit integer.

pack-priv static native long
invokeL1NoErrno(long ctx, long function, long arg1)

pack-priv static native long

Returns:

A 64 bit integer value.
invokeL2
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first 64 bit integer argument.
arg1
,
long
The second 64 bit integer argument.
arg2
)

Invokes a function with two 64 bit integer arguments, and returns a 64 bit integer.

pack-priv static native long
invokeL2NoErrno(long ctx, long function, long arg1, long arg2)

pack-priv static native long

Returns:

A 64 bit integer value.
invokeL3
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first 64 bit integer argument.
arg1
,
long
The second 64 bit integer argument.
arg2
,
long
The third 64 bit integer argument.
arg3
)

Invokes a function with three 64 bit integer arguments, and returns a 64 bit integer.

pack-priv static native long
invokeL3NoErrno(long ctx, long function, long arg1, long arg2, long arg3)

pack-priv static native long

Returns:

A 64 bit integer value.
invokeL4
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first 64 bit integer argument.
arg1
,
long
The second 64 bit integer argument.
arg2
,
long
The third 64 bit integer argument.
arg3
,
long
The fourth 64 bit integer argument.
arg4
)

Invokes a function with four 64 bit integer arguments, and returns a 64 bit integer.

pack-priv static native long
invokeL4NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4)

pack-priv static native long

Returns:

A 64 bit integer value.
invokeL5
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first 64 bit integer argument.
arg1
,
long
The second 64 bit integer argument.
arg2
,
long
The third 64 bit integer argument.
arg3
,
long
The fourth 64 bit integer argument.
arg4
,
long
The fifth 64 bit integer argument.
arg5
)

Invokes a function with five 64 bit integer arguments, and returns a 64 bit integer.

pack-priv static native long
invokeL5NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5)

pack-priv static native long

Returns:

A 64 bit integer value.
invokeL6
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first 64 bit integer argument.
arg1
,
long
The second 64 bit integer argument.
arg2
,
long
The third 64 bit integer argument.
arg3
,
long
The fourth 64 bit integer argument.
arg4
,
long
The fifth 64 bit integer argument.
arg5
,
long
The sixth 64 bit integer argument.
arg6
)

Invokes a function with six 64 bit integer arguments, and returns a 64 bit integer.

pack-priv static native long
invokeL6NoErrno(long ctx, long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)

pack-priv static native long

Returns:

A numeric value.
invokeN0
(long ctx, long
The address of the function context structure from newCallContext.
function
)

Invokes a function with zero numeric arguments, and returns a numeric value.

pack-priv static native long

Returns:

A numeric value.
invokeN1
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first numeric argument.
arg1
)

Invokes a function with one numeric arguments, and returns a numeric value.

pack-priv static native long
invokeN1O1(long
The FFI call context describing the function to invoke.
callContext
,
long
The native function to invoke.
functionAddress
,
long
The first numeric argument.
n1
,
Object
An Object (array or buffer), to be passed as a pointer.
o1
,
int
Object flags (direction, type, idx).
o1flags
,
int
The offset from the start of the array or buffer.
o1off
,
int
The length of the array to use.
o1len
)

Invokes a function with one numeric argument, and returns a numeric value.

pack-priv static native long

Returns:

A numeric value.
invokeN2
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first numeric argument.
arg1
,
long
The second numeric argument.
arg2
)

Invokes a function with two numeric arguments, and returns a numeric value.

pack-priv static native long

Returns:

A numeric value.
invokeN2O1
(long
The FFI call context describing the function to invoke.
callContext
,
long
The native function to invoke.
functionAddress
,
long
The first numeric argument.
n1
,
long
The second numeric argument.
n2
,
Object
An Object (array or buffer), to be passed as a pointer.
o1
,
int
Object flags (direction, type, idx).
o1flags
,
int
The offset from the start of the array or buffer.
o1off
,
int
The length of the array to use.
o1len
)

Invokes a function with two numeric arguments, and returns a numeric value.

pack-priv static native long

Returns:

A numeric value.
invokeN2O2
(long
The FFI call context describing the function to invoke.
callContext
,
long
The native function to invoke.
functionAddress
,
long
The first numeric argument.
n1
,
long
The second numeric argument.
n2
,
Object
An Object (array or buffer), to be passed as a pointer.
o1
,
int
Object flags (direction, type, idx).
o1flags
,
int
The offset from the start of the array or buffer.
o1off
,
int
The length of the array to use.
o1len
,
Object
An Object (array or buffer), to be passed as a pointer.
o2
,
int
Object flags (direction, type, idx).
o2flags
,
int
The offset from the start of the array or buffer.
o2off
,
int
The length of the array to use.
o2len
)

Invokes a function with two numeric arguments, and returns a numeric value.

pack-priv static native long

Returns:

A numeric value.
invokeN3
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first numeric argument.
arg1
,
long
The second numeric argument.
arg2
,
long
The third numeric argument.
arg3
)

Invokes a function with three numeric arguments, and returns a numeric value.

pack-priv static native long

Returns:

A numeric value.
invokeN3O1
(long
The FFI call context describing the function to invoke.
callContext
,
long
The native function to invoke.
functionAddress
,
long
The first numeric argument.
n1
,
long
The second numeric argument.
n2
,
long
The third numeric argument.
n3
,
Object
An Object (array or buffer), to be passed as a pointer.
o1
,
int
Object flags (direction, type, parameter index).
o1flags
,
int
The offset from the start of the array or buffer.
o1off
,
int
The length of the array to use.
o1len
)

Invokes a function with three numeric arguments, and returns a numeric value.

pack-priv static native long
invokeN3O2(long callContext, long functionAddress, long n1, long n2, long n3, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len)

pack-priv static native long
invokeN3O3(long callContext, long functionAddress, long n1, long n2, long n3, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len)

pack-priv static native long

Returns:

A numeric value.
invokeN4
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first numeric argument.
arg1
,
long
The second numeric argument.
arg2
,
long
The third numeric argument.
arg3
,
long
The fourth numeric argument.
arg4
)

Invokes a function with four numeric arguments, and returns a numeric value.

pack-priv static native long
invokeN4O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len)

pack-priv static native long
invokeN4O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len)

pack-priv static native long
invokeN4O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len)

pack-priv static native long
invokeN4O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len)

pack-priv static native long

Returns:

A numeric value.
invokeN5
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first numeric argument.
arg1
,
long
The second numeric argument.
arg2
,
long
The third numeric argument.
arg3
,
long
The fourth numeric argument.
arg4
,
long
The fifth numeric argument.
arg5
)

Invokes a function with five numeric arguments, and returns a numeric value.

pack-priv static native long
invokeN5O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len)

pack-priv static native long
invokeN5O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len)

pack-priv static native long
invokeN5O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len)

pack-priv static native long
invokeN5O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len)

pack-priv static native long
invokeN5O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, Object o5, int o5flags, int o5off, int o5len)

pack-priv static native long

Returns:

A numeric value.
invokeN6
(long ctx, long
The address of the function context structure from newCallContext.
function
,
long
The first numeric argument.
arg1
,
long
The second numeric argument.
arg2
,
long
The third numeric argument.
arg3
,
long
The fourth numeric argument.
arg4
,
long
The fifth numeric argument.
arg5
,
long
The sixth numeric argument.
arg6
)

Invokes a function with six numeric arguments, and returns a numeric value.

pack-priv static native long
invokeN6O1(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len)

pack-priv static native long
invokeN6O2(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len)

pack-priv static native long
invokeN6O3(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len)

pack-priv static native long
invokeN6O4(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len)

pack-priv static native long
invokeN6O5(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, Object o5, int o5flags, int o5off, int o5len)

pack-priv static native long
invokeN6O6(long callContext, long functionAddress, long n1, long n2, long n3, long n4, long n5, long n6, Object o1, int o1flags, int o1off, int o1len, Object o2, int o2flags, int o2off, int o2len, Object o3, int o3flags, int o3off, int o3len, Object o4, int o4flags, int o4off, int o4len, Object o5, int o5flags, int o5off, int o5len, Object o6, int o6flags, int o6off, int o6len)

pack-priv static native void
invokePointerParameterArray(long callContext, long
The address of the function context structure from newCallContext.
functionContext
,
long
The address of the native buffer to place the result of the function call in.
returnBuffer
,
long[]
An array of addresses of the function parameters.
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 native boolean
pack-priv static boolean
pack-priv final native boolean
pack-priv final native void
longDoubleFromDouble(double doubleValue, byte[] buf, int off, int len)

pack-priv final native void
longDoubleFromString(String doubleString, byte[] buf, int off, int len)

pack-priv final native double
longDoubleToDouble(byte[] buf, int off, int len)

pack-priv final native String
longDoubleToEngineeringString(byte[] buf, int off, int len)

pack-priv final native String
longDoubleToPlainString(byte[] buf, int off, int len)

pack-priv final native String
longDoubleToString(byte[] buf, int off, int len)

pack-priv final native long

Returns:

The address of the ffi_type struct for this type, or null
lookupBuiltinType
(int
The FFI type enum value
type
)

Gets the address of the ffi_type structure for the builtin type

pack-priv static native long

Returns:

The address of the value, or 0 (zero) if not found.
memchr
(long
The native memory address to start searching.
address
,
int
The value to search for.
value
,
long
The size of the native memory region being searched.
len
)

Gets the address of a byte value in a native memory region.

pack-priv static native long

Returns:

The address of the value, or 0 (zero) if not found.
memchrChecked
(long
The native memory address to start searching.
address
,
int
The value to search for.
value
,
long
The size of the native memory region being searched.
len
)

Gets the address of a byte value in a native memory region.

pack-priv static native void
memcpy(long
The destination memory address.
dst
,
long
The source memory address.
src
,
long
The number of bytes to copy.
len
)

Copies non-overlapping memory areas.

pack-priv static native void
memcpyChecked(long
The destination memory address.
dst
,
long
The source memory address.
src
,
long
The number of bytes to copy.
len
)

Copies non-overlapping memory areas.

pack-priv static native void
memmove(long
The destination memory address.
dst
,
long
The source memory address.
src
,
long
The number of bytes to copy.
len
)

Copies potentially overlapping memory areas.

pack-priv static native void
memmoveChecked(long
The destination memory address.
dst
,
long
The source memory address.
src
,
long
The number of bytes to copy.
len
)

Copies potentially overlapping memory areas.

pack-priv static native long

Returns:

The address of the mapping on success, -1 on error.
mmap
(long
The desired address to map the memory at, or 0 for random address.
addr
,
long
The length of the memory region.
len
,
int
The protection mode for the memory region.
prot
,
int flags, int fd, long off)

Calls the Unix mmap(2) function This method is undefined on windows.

pack-priv static native int

Returns:

0 on success, -1 on error.
mprotect
(long
The address to unmap.
addr
,
long
The size of the region.
len
,
int
The new protection mode.
prot
)

Calls the Unix mprotect(2) function.

pack-priv static native int

Returns:

0 on success, -1 on error.
munmap
(long
The address to unmap.
addr
,
long
The size of the region.
len
)

Calls the Unix munmap(2) function.

pack-priv final native long

Returns:

The native address of the ffi_type structure for the new array layout.
newArray
(long
the type of each element in the array.
elementType
,
int
the number of elements in the array.
length
)

Allocates a new FFI array type.

pack-priv final native long

Returns:

The native address of a new function context
newCallContext
(long
The return type of the function
returnType
,
long[]
The types of the parameters
paramTypes
,
int
A bitmask of F_DEFAULT, F_STDCALL, F_NOERRNO, F_PROTECT and the fixed param count in the high word.
flags
)

Creates a new native call context.

pack-priv final native long
newClosureMagazine(long contextAddress, Method closureMethod, boolean callWithPrimitiveParameters)

pack-priv final native ByteBuffer

Returns:

A ByteBuffer representing the native memory region.
newDirectByteBuffer
(long
The start of the native memory region.
address
,
int
The size of the native memory region.
capacity
)

Creates a new Direct ByteBuffer for a native memory region.

private static UnsatisfiedLinkError
pack-priv final native long
newNativeMethod(String name, String signature, long functionContext)

pack-priv final native long

Returns:

The native address of the ffi_type structure for the new struct layout
newStruct
(long[]
An array of ffi_type pointers describing the fields of the struct
fields
,
boolean
If true, then fields are all positioned at offset=0, else fields are sequentially positioned.
isUnion
)

Allocates a new FFI struct or union layout

pack-priv static native long

Returns:

The size of a memory page in bytes.
pageSize
()

Gets the size of a page of memory.

pack-priv static native void
putAddress(long
The memory location to put the value.
address
,
long
The value to write to memory.
value
)

Writes a native memory address value to a native memory location.

pack-priv static native void
putAddressChecked(long
The memory location to put the value.
address
,
long
The value to write to memory.
value
)

Writes a native memory address value to a native memory location.

pack-priv static native void
putByte(long
The memory location to put the value.
address
,
byte
The value to write to memory.
value
)

Writes an 8 bit integer value to a native memory location.

pack-priv static native void
putByteArray(long
The native memory address to copy the array to.
address
,
byte[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java byte array to native memory.

pack-priv static native void
putByteArrayChecked(long
The native memory address to copy the array to.
address
,
byte[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java byte array to native memory.

pack-priv static native void
putByteChecked(long
The memory location to put the value.
address
,
byte
The value to write to memory.
value
)

Writes an 8 bit integer value to a native memory location.

pack-priv static native void
putCharArray(long
The native memory address to copy the array to.
address
,
char[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java char array to native memory.

pack-priv static native void
putCharArrayChecked(long
The native memory address to copy the array to.
address
,
char[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java char array to native memory.

pack-priv static native void
putDouble(long
The memory location to put the value.
address
,
double
The value to write to memory.
value
)

Writes a 64 bit floating point value to a native memory location.

pack-priv static native void
putDoubleArray(long
The native memory address to copy the array to.
address
,
double[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java double array to native memory.

pack-priv static native void
putDoubleArrayChecked(long
The native memory address to copy the array to.
address
,
double[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java double array to native memory.

pack-priv static native void
putDoubleChecked(long
The memory location to put the value.
address
,
double
The value to write to memory.
value
)

Writes a 64 bit floating point value to a native memory location.

pack-priv static native void
putFloat(long
The memory location to put the value.
address
,
float
The value to write to memory.
value
)

Writes a 32 bit floating point value to a native memory location.

pack-priv static native void
putFloatArray(long
The native memory address to copy the array to.
address
,
float[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java double array to native memory.

pack-priv static native void
putFloatArrayChecked(long
The native memory address to copy the array to.
address
,
float[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java double array to native memory.

pack-priv static native void
putFloatChecked(long
The memory location to put the value.
address
,
float
The value to write to memory.
value
)

Writes a 32 bit floating point value to a native memory location.

pack-priv static native void
putInt(long
The memory location to put the value.
address
,
int
The value to write to memory.
value
)

Writes a 32 bit integer value to a native memory location.

pack-priv static native void
putIntArray(long
The native memory address to copy the array to.
address
,
int[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java int array to native memory.

pack-priv static native void
putIntArrayChecked(long
The native memory address to copy the array to.
address
,
int[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java int array to native memory.

pack-priv static native void
putIntChecked(long
The memory location to put the value.
address
,
int
The value to write to memory.
value
)

Writes a 32 bit integer value to a native memory location.

pack-priv static native void
putLong(long
The memory location to put the value.
address
,
long
The value to write to memory.
value
)

Writes a 64 bit integer value to a native memory location.

pack-priv static native void
putLongArray(long
The native memory address to copy the array to.
address
,
long[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java long array to native memory.

pack-priv static native void
putLongArrayChecked(long
The native memory address to copy the array to.
address
,
long[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java long array to native memory.

pack-priv static native void
putLongChecked(long
The memory location to put the value.
address
,
long
The value to write to memory.
value
)

Writes a 64 bit integer value to a native memory location.

pack-priv static native void
putShort(long
The memory location to put the value.
address
,
short
The value to write to memory.
value
)

Writes a 16 bit integer value to a native memory location.

pack-priv static native void
putShortArray(long
The native memory address to copy the array to.
address
,
short[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java short array to native memory.

pack-priv static native void
putShortArrayChecked(long
The native memory address to copy the array to.
address
,
short[]
The java array to copy.
data
,
int
The offset within the array to start copying from.
offset
,
int
The number of array elements to copy.
length
)

Writes a java short array to native memory.

pack-priv static native void
putShortChecked(long
The memory location to put the value.
address
,
short
The value to write to memory.
value
)

Writes a 16 bit integer value to a native memory location.

pack-priv static native void
putZeroTerminatedByteArray(long
The address to copy to.
address
,
byte[]
The byte array to copy to native memory
data
,
int
The offset within the byte array to begin copying from
offset
,
int
The number of bytes to copy to native memory
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.

pack-priv static native void
putZeroTerminatedByteArrayChecked(long
The address to copy to.
address
,
byte[]
The byte array to copy to native memory
data
,
int
The offset within the byte array to begin copying from
offset
,
int
The number of bytes to copy to native memory
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.

pack-priv final native boolean

Returns:

true if successful
registerNativeMethods
(Class<T>
The java class to register the native methods on
clazz
,
long
The handle returned from compileNativeMethods
handle
)

pack-priv final native int
registerNatives(Class<T> clazz, long methods, int methodCount)

pack-priv final native void
setCallContextErrorFunction(long ctx, long fn)

pack-priv static native void
setLastError(int
The value to set errno to.
error
)

Sets the native errno value

pack-priv static native void
setMemory(long
The address of start of the native memory.
address
,
long
The number of bytes to set.
size
,
byte
The value to set the native memory to.
value
)

Sets a region of native memory to a specific byte value.

pack-priv static native void
setMemoryChecked(long
The address of start of the native memory.
address
,
long
The number of bytes to set.
size
,
byte
The value to set the native memory to.
value
)

Sets a region of native memory to a specific byte value.

pack-priv static native long

Returns:

The length of the string, in bytes.
strlen
(long
The native address of the string.
address
)

Gets the length of a native ascii or utf-8 string.

pack-priv static native long

Returns:

The length of the string, in bytes.
strlenChecked
(long
The native address of the string.
address
)

Gets the length of a native ascii or utf-8 string.

pack-priv final native void
pack-priv final native int
pack-priv static native long
VirtualAlloc(long addr, int size, int flags, int prot)

pack-priv static native boolean
VirtualFree(long addr, int size, int flags)

pack-priv static native boolean
VirtualProtect(long addr, int size, int prot)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait