Package com.oracle.nfi.api
Interface NativeFunctionInterface
public interface NativeFunctionInterface
-
Method Summary
Modifier and TypeMethodDescriptiongetFunctionHandle(NativeFunctionPointer functionPointer, Class<?> returnType, Class<?>... argumentTypes) Resolves a function pointer to a handle that can be called with a given signature.getFunctionHandle(NativeLibraryHandle[] libraries, String name, Class<?> returnType, Class<?>... argumentTypes) Resolves a function name to a handle that can be called with a given signature.getFunctionHandle(NativeLibraryHandle library, String name, Class<?> returnType, Class<?>... argumentTypes) Resolves a function name to a handle that can be called with a given signature.getFunctionHandle(String name, Class<?> returnType, Class<?>... argumentTypes) Resolves a function name to a handle that can be called with a given signature.getFunctionPointer(NativeLibraryHandle[] libraries, String name) Resolves the function pointerNativeFunctionPointerof a native function.getLibraryHandle(String libPath) Resolves and returns a handle to an open native library.getNativeFunctionPointerFromRawValue(long rawValue) Creates aNativeFunctionPointerfrom a raw value.booleanDetermines if the underlying platform/runtime supports the notion of a default library search path.
-
Method Details
-
getLibraryHandle
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:
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
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, String name, Class<?> returnType, 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, Class<?> returnType, 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, String name, Class<?> returnType, 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
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
Creates aNativeFunctionPointerfrom a raw value.- Parameters:
rawValue- raw function pointer- Returns:
NativeFunctionPointerforrawValue
-