APIdia Launch Partner
Top Inners Fields Constructors Methods
jdk.internal.foreign.abi.fallback

pack-priv final Class LibFallback

extends Object
Class Inheritance
Imports
jdk.internal.foreign.abi.SharedUtils, java.lang.foreign.Arena, .MemorySegment, java.lang.invoke.MethodHandle, .MethodType

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
pack-priv static final boolean
private static final MethodType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static native int
private static native int
private static void
checkStatus(int code)

pack-priv static MemorySegment

Returns:

the created upcall stub
createClosure
(MemorySegment
a pointer to a ffi_cif struct
cif
,
MethodHandle
a method handle that points to the target function
target
,
Arena
the scope to which to attach the created upcall stub
arena
)

Create an upcallStub-style closure.

private static native int
createClosure(long cif, Object userData, long[] ptrs)

pack-priv static int
pack-priv static void
doDowncall(MemorySegment
a pointer to a ffi_cif struct
cif
,
MemorySegment
the address of the target function
target
,
MemorySegment
a pointer to a buffer into which the return value shall be written, or null if the target function does not return a value
retPtr
,
MemorySegment
a pointer to an array of pointers, which each point to an argument value
argPtrs
,
Object captureStateHeapBase, MemorySegment
a pointer to a buffer into which captured state is written, or null if no state is to be captured
capturedState
,
int
the bit mask indicating which state to capture
capturedStateMask
,
Object[] heapBases, int numArgs)

Do a libffi based downcall.

private static native void
doDowncall(long cif, long fn, long rvalue, long avalues, Object captureStateHeapBase, long capturedState, int capturedStateMask, Object[] heapBases, int numArgs)

pack-priv static int
pack-priv static MemorySegment
private static void
doUpcall(long retPtr, long argPtrs, MethodHandle target)

private static native int
private static native int
ffi_get_struct_offsets(int abi, long type, long offsets)

private static native int
ffi_prep_cif(long cif, int abi, int nargs, long rtype, long atypes)

private static native int
ffi_prep_cif_var(long cif, int abi, int nfixedargs, int ntotalargs, long rtype, long atypes)

private static native int
private static native int
private static native int
private static native int
private static native long
private static native long
private static native long
private static native long
private static native long
private static native long
private static native long
private static native short
private static native long
private static native long
private static native long
private static native long
private static native long
pack-priv static MemorySegment
private static native void
freeClosure(long closureAddress, long globalTarget)

pack-priv static void
getStructOffsets(MemorySegment
a pointer to an ffi_type representing a struct
structType
,
MemorySegment
a pointer to an array of size_t, with one element for each element of the struct. This is an 'out' parameter that will be filled in by this call
offsetsOut
,
FFIABI
the abi to be used
abi
)

Wrapper for ffi_get_struct_offsets

private static native boolean
init()

pack-priv static int
pack-priv static int
pack-priv static int
pack-priv static MemorySegment
pack-priv static MemorySegment

Returns:

a pointer to a prepared ffi_cif struct
prepCif
(MemorySegment
a pointer to an @{code ffi_type} describing the return type
returnType
,
int
the number of arguments
numArgs
,
MemorySegment
a pointer to an array of pointers, which each point to an ffi_type describing a parameter type
paramTypes
,
FFIABI
the abi to be used
abi
,
Arena
the scope into which to allocate the returned ffi_cif struct
scope
)

Wrapper for ffi_prep_cif

pack-priv static MemorySegment

Returns:

a pointer to a prepared ffi_cif struct
prepCifVar
(MemorySegment
a pointer to an @{code ffi_type} describing the return type
returnType
,
int
the number of fixed arguments
numFixedArgs
,
int
the number of total arguments
numTotalArgs
,
MemorySegment
a pointer to an array of pointers, which each point to an ffi_type describing a parameter type
paramTypes
,
FFIABI
the abi to be used
abi
,
Arena
the scope into which to allocate the returned ffi_cif struct
scope
)

Wrapper for ffi_prep_cif_var.

pack-priv static int
pack-priv static MemorySegment
pack-priv static MemorySegment
pack-priv static MemorySegment
pack-priv static MemorySegment
private static native long
pack-priv static short
private static boolean
pack-priv static MemorySegment
pack-priv static MemorySegment
pack-priv static MemorySegment
pack-priv static int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SUPPORTEDback to summary
pack-priv static final boolean SUPPORTED
UPCALL_TARGET_TYPEback to summary
private static final MethodType UPCALL_TARGET_TYPE

Constructor Detail

LibFallbackback to summary
private LibFallback()

Method Detail

alignof_doubleback to summary
private static native int alignof_double()
alignof_long_longback to summary
private static native int alignof_long_long()
checkStatusback to summary
private static void checkStatus(int code)
createClosureback to summary
pack-priv static MemorySegment createClosure(MemorySegment cif, MethodHandle target, Arena arena) throws IllegalStateException, IllegalArgumentException

Create an upcallStub-style closure. This method wraps the ffi_closure_alloc and ffi_prep_closure_loc functions.

The closure will end up calling into doUpcall(long, long, MethodHandle)

The target method handle should have the type (MemorySegment, MemorySegment) -> void. The first argument is a pointer to the buffer into which the native return value should be written. The second argument is a pointer to an array of pointers, which each point to a native argument value.

Parameters
cif:MemorySegment

a pointer to a ffi_cif struct

target:MethodHandle

a method handle that points to the target function

arena:Arena

the scope to which to attach the created upcall stub

Returns:MemorySegment

the created upcall stub

Annotations
@SuppressWarnings:restricted
Exceptions
IllegalStateException:
if the call to ffi_prep_closure_loc returns a non-zero status code
IllegalArgumentException:
if target does not have the right type
createClosureback to summary
private static native int createClosure(long cif, Object userData, long[] ptrs)
defaultABIback to summary
pack-priv static int defaultABI()
doDowncallback to summary
pack-priv static void doDowncall(MemorySegment cif, MemorySegment target, MemorySegment retPtr, MemorySegment argPtrs, Object captureStateHeapBase, MemorySegment capturedState, int capturedStateMask, Object[] heapBases, int numArgs)

Do a libffi based downcall. This method wraps the ffi_call function

Parameters
cif:MemorySegment

a pointer to a ffi_cif struct

target:MemorySegment

the address of the target function

retPtr:MemorySegment

a pointer to a buffer into which the return value shall be written, or null if the target function does not return a value

argPtrs:MemorySegment

a pointer to an array of pointers, which each point to an argument value

capturedState:MemorySegment

a pointer to a buffer into which captured state is written, or null if no state is to be captured

capturedStateMask:int

the bit mask indicating which state to capture

See Also
jdk.internal.foreign.abi.CapturableState
doDowncallback to summary
private static native void doDowncall(long cif, long fn, long rvalue, long avalues, Object captureStateHeapBase, long capturedState, int capturedStateMask, Object[] heapBases, int numArgs)
doubleAlignback to summary
pack-priv static int doubleAlign()
doubleTypeback to summary
pack-priv static MemorySegment doubleType()
doUpcallback to summary
private static void doUpcall(long retPtr, long argPtrs, MethodHandle target)
ffi_default_abiback to summary
private static native int ffi_default_abi()
ffi_get_struct_offsetsback to summary
private static native int ffi_get_struct_offsets(int abi, long type, long offsets)
ffi_prep_cifback to summary
private static native int ffi_prep_cif(long cif, int abi, int nargs, long rtype, long atypes)
ffi_prep_cif_varback to summary
private static native int ffi_prep_cif_var(long cif, int abi, int nfixedargs, int ntotalargs, long rtype, long atypes)
ffi_sizeof_intback to summary
private static native int ffi_sizeof_int()
ffi_sizeof_longback to summary
private static native int ffi_sizeof_long()
ffi_sizeof_shortback to summary
private static native int ffi_sizeof_short()
ffi_sizeof_wcharback to summary
private static native int ffi_sizeof_wchar()
ffi_type_doubleback to summary
private static native long ffi_type_double()
ffi_type_floatback to summary
private static native long ffi_type_float()
ffi_type_pointerback to summary
private static native long ffi_type_pointer()
ffi_type_sint16back to summary
private static native long ffi_type_sint16()
ffi_type_sint32back to summary
private static native long ffi_type_sint32()
ffi_type_sint64back to summary
private static native long ffi_type_sint64()
ffi_type_sint8back to summary
private static native long ffi_type_sint8()
ffi_type_structback to summary
private static native short ffi_type_struct()
ffi_type_uint16back to summary
private static native long ffi_type_uint16()
ffi_type_uint32back to summary
private static native long ffi_type_uint32()
ffi_type_uint64back to summary
private static native long ffi_type_uint64()
ffi_type_uint8back to summary
private static native long ffi_type_uint8()
ffi_type_voidback to summary
private static native long ffi_type_void()
floatTypeback to summary
pack-priv static MemorySegment floatType()
freeClosureback to summary
private static native void freeClosure(long closureAddress, long globalTarget)
getStructOffsetsback to summary
pack-priv static void getStructOffsets(MemorySegment structType, MemorySegment offsetsOut, FFIABI abi) throws IllegalStateException

Wrapper for ffi_get_struct_offsets

Parameters
structType:MemorySegment

a pointer to an ffi_type representing a struct

offsetsOut:MemorySegment

a pointer to an array of size_t, with one element for each element of the struct. This is an 'out' parameter that will be filled in by this call

abi:FFIABI

the abi to be used

Exceptions
IllegalStateException:
if the call to ffi_get_struct_offsets returns a non-zero status code
initback to summary
private static native boolean init()
intSizeback to summary
pack-priv static int intSize()
longLongAlignback to summary
pack-priv static int longLongAlign()
longSizeback to summary
pack-priv static int longSize()
pointerTypeback to summary
pack-priv static MemorySegment pointerType()
prepCifback to summary
pack-priv static MemorySegment prepCif(MemorySegment returnType, int numArgs, MemorySegment paramTypes, FFIABI abi, Arena scope) throws IllegalStateException

Wrapper for ffi_prep_cif

Parameters
returnType:MemorySegment

a pointer to an @{code ffi_type} describing the return type

numArgs:int

the number of arguments

paramTypes:MemorySegment

a pointer to an array of pointers, which each point to an ffi_type describing a parameter type

abi:FFIABI

the abi to be used

scope:Arena

the scope into which to allocate the returned ffi_cif struct

Returns:MemorySegment

a pointer to a prepared ffi_cif struct

Exceptions
IllegalStateException:
if the call to ffi_prep_cif returns a non-zero status code
prepCifVarback to summary
pack-priv static MemorySegment prepCifVar(MemorySegment returnType, int numFixedArgs, int numTotalArgs, MemorySegment paramTypes, FFIABI abi, Arena scope) throws IllegalStateException

Wrapper for ffi_prep_cif_var. The variadic version of prep_cif

Parameters
returnType:MemorySegment

a pointer to an @{code ffi_type} describing the return type

numFixedArgs:int

the number of fixed arguments

numTotalArgs:int

the number of total arguments

paramTypes:MemorySegment

a pointer to an array of pointers, which each point to an ffi_type describing a parameter type

abi:FFIABI

the abi to be used

scope:Arena

the scope into which to allocate the returned ffi_cif struct

Returns:MemorySegment

a pointer to a prepared ffi_cif struct

Exceptions
IllegalStateException:
if the call to ffi_prep_cif returns a non-zero status code
shortSizeback to summary
pack-priv static int shortSize()
sint16Typeback to summary
pack-priv static MemorySegment sint16Type()
sint32Typeback to summary
pack-priv static MemorySegment sint32Type()
sint64Typeback to summary
pack-priv static MemorySegment sint64Type()
sint8Typeback to summary
pack-priv static MemorySegment sint8Type()
sizeofCifback to summary
private static native long sizeofCif()
structTagback to summary
pack-priv static short structTag()
tryLoadLibraryback to summary
private static boolean tryLoadLibrary()
Annotations
@SuppressWarnings:restricted
uint16Typeback to summary
pack-priv static MemorySegment uint16Type()
uint8Typeback to summary
pack-priv static MemorySegment uint8Type()
voidTypeback to summary
pack-priv static MemorySegment voidType()
wcharSizeback to summary
pack-priv static int wcharSize()
jdk.internal.foreign.abi.fallback back to summary

private final Class LibFallback.NativeConstants

extends Object
Class Inheritance
  • java.lang.Object
  • jdk.internal.foreign.abi.fallback.LibFallback.NativeConstants

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final MemorySegment
pack-priv static final MemorySegment
pack-priv static final MemorySegment
pack-priv static final MemorySegment
pack-priv static final MemorySegment
pack-priv static final MemorySegment
pack-priv static final MemorySegment
pack-priv static final long
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final short
pack-priv static final MemorySegment
pack-priv static final MemorySegment
pack-priv static final MemorySegment

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALIGNOF_DOUBLEback to summary
pack-priv static final int ALIGNOF_DOUBLE
ALIGNOF_LONG_LONGback to summary
pack-priv static final int ALIGNOF_LONG_LONG
DEFAULT_ABIback to summary
pack-priv static final int DEFAULT_ABI
DOUBLE_TYPEback to summary
pack-priv static final MemorySegment DOUBLE_TYPE
FLOAT_TYPEback to summary
pack-priv static final MemorySegment FLOAT_TYPE
POINTER_TYPEback to summary
pack-priv static final MemorySegment POINTER_TYPE
SINT16_TYPEback to summary
pack-priv static final MemorySegment SINT16_TYPE
SINT32_TYPEback to summary
pack-priv static final MemorySegment SINT32_TYPE
SINT64_TYPEback to summary
pack-priv static final MemorySegment SINT64_TYPE
SINT8_TYPEback to summary
pack-priv static final MemorySegment SINT8_TYPE
SIZEOF_CIFback to summary
pack-priv static final long SIZEOF_CIF
SIZEOF_INTback to summary
pack-priv static final int SIZEOF_INT
SIZEOF_LONGback to summary
pack-priv static final int SIZEOF_LONG
SIZEOF_SHORTback to summary
pack-priv static final int SIZEOF_SHORT
SIZEOF_WCHARback to summary
pack-priv static final int SIZEOF_WCHAR
STRUCT_TAGback to summary
pack-priv static final short STRUCT_TAG
UINT16_TYPEback to summary
pack-priv static final MemorySegment UINT16_TYPE
UINT8_TYPEback to summary
pack-priv static final MemorySegment UINT8_TYPE
VOID_TYPEback to summary
pack-priv static final MemorySegment VOID_TYPE

Constructor Detail

NativeConstantsback to summary
private NativeConstants()