Package com.oracle.nfi.api
Interface NativeFunctionInterface
-
public interface NativeFunctionInterface
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NativeFunctionHandlegetFunctionHandle(NativeFunctionPointer functionPointer, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)Resolves a function pointer to a handle that can be called with a given signature.NativeFunctionHandlegetFunctionHandle(NativeLibraryHandle[] libraries, java.lang.String name, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)Resolves a function name to a handle that can be called with a given signature.NativeFunctionHandlegetFunctionHandle(NativeLibraryHandle library, java.lang.String name, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)Resolves a function name to a handle that can be called with a given signature.NativeFunctionHandlegetFunctionHandle(java.lang.String name, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)Resolves a function name to a handle that can be called with a given signature.NativeFunctionPointergetFunctionPointer(NativeLibraryHandle[] libraries, java.lang.String name)Resolves the function pointerNativeFunctionPointerof a native function.NativeLibraryHandlegetLibraryHandle(java.lang.String libPath)Resolves and returns a handle to an open native library.NativeFunctionPointergetNativeFunctionPointerFromRawValue(long rawValue)Creates aNativeFunctionPointerfrom a raw value.booleanisDefaultLibrarySearchSupported()Determines if the underlying platform/runtime supports the notion of a default library search path.
-
-
-
Method Detail
-
getLibraryHandle
NativeLibraryHandle getLibraryHandle(java.lang.String libPath)
Resolves and returns a handle to an open native library. This method will open the library only if it is not already open.- Parameters:
libPath- the absolute path to the library- Returns:
- the resolved library handle
- Throws:
java.lang.UnsatisfiedLinkError- if the library could not be found or opened
-
isDefaultLibrarySearchSupported
boolean isDefaultLibrarySearchSupported()
Determines if the underlying platform/runtime supports the notion of a default library search path. For example, on *nix systems, this is typically defined by theLD_LIBRARY_PATHenvironment variable.
-
getFunctionPointer
NativeFunctionPointer getFunctionPointer(NativeLibraryHandle[] libraries, java.lang.String name)
Resolves the function pointerNativeFunctionPointerof a native function.- Parameters:
libraries- the ordered list of libraries to search for the functionname- the name of the function to be resolved- Returns:
- a pointer to the native function, or
nullif the function pointer could not be resolved
-
getFunctionHandle
NativeFunctionHandle getFunctionHandle(NativeLibraryHandle library, java.lang.String name, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)
Resolves a function name to a handle that can be called with a given signature. The signature contains the types of the arguments that will be passed to the handle when it is called.- Parameters:
library- the handle to a resolved libraryname- the name of the function to be resolvedreturnType- the type of the return valueargumentTypes- the types of the arguments- Returns:
- the function handle of the native function, or
nullif the function handle could not be resolved
-
getFunctionHandle
NativeFunctionHandle getFunctionHandle(NativeFunctionPointer functionPointer, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)
Resolves a function pointer to a handle that can be called with a given signature. The signature contains the types of the arguments that will be passed to the handle when it is called.- Parameters:
functionPointer- a function pointerreturnType- the type of the return valueargumentTypes- the types of the arguments- Returns:
- the function handle of the native function, or
nullif the function handle could not be resolved
-
getFunctionHandle
NativeFunctionHandle getFunctionHandle(NativeLibraryHandle[] libraries, java.lang.String name, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)
Resolves a function name to a handle that can be called with a given signature. The signature contains the types of the arguments that will be passed to the handle when it is called.- Parameters:
libraries- the ordered list of libraries to search for the functionname- the name of the function to be resolvedreturnType- the type of the return valueargumentTypes- the types of the arguments- Returns:
- the function handle of the native function, or
nullif the function handle could not be resolved
-
getFunctionHandle
NativeFunctionHandle getFunctionHandle(java.lang.String name, java.lang.Class<?> returnType, java.lang.Class<?>... argumentTypes)
Resolves a function name to a handle that can be called with a given signature. The signature contains the types of the arguments that will be passed to the handle when it is called.- Parameters:
name- the name of the function to be resolvedreturnType- the type of the return valueargumentTypes- the types of the arguments- Returns:
- the function handle of the native function, or
nullif default library searching is not supported or if the function could not be resolved
-
getNativeFunctionPointerFromRawValue
NativeFunctionPointer getNativeFunctionPointerFromRawValue(long rawValue)
Creates aNativeFunctionPointerfrom a raw value.- Parameters:
rawValue- raw function pointer- Returns:
NativeFunctionPointerforrawValue
-
-