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 pointerNativeFunctionPointer
of a native function.getLibraryHandle
(String libPath) Resolves and returns a handle to an open native library.getNativeFunctionPointerFromRawValue
(long rawValue) Creates aNativeFunctionPointer
from a raw value.boolean
Determines 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_PATH
environment variable. -
getFunctionPointer
Resolves the function pointerNativeFunctionPointer
of 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
null
if 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
null
if 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
null
if 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
null
if 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
null
if default library searching is not supported or if the function could not be resolved
-
getNativeFunctionPointerFromRawValue
Creates aNativeFunctionPointer
from a raw value.- Parameters:
rawValue
- raw function pointer- Returns:
NativeFunctionPointer
forrawValue
-