com.oracle.nfi.api

## Interface NativeFunctionInterface

    public interface NativeFunctionInterface

Interface to get a handle or pointer to a native function or a handle to an open native library.

### Method Summary

Methods
`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.
`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.
`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.
`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.
`NativeFunctionPointer` `getFunctionPointer(NativeLibraryHandle[] libraries, java.lang.String name)` Resolves the function pointer `NativeFunctionPointer` of a native function.
`NativeLibraryHandle` `getLibraryHandle(java.lang.String libPath)` Resolves and returns a handle to an open native library.
`NativeFunctionPointer` `getNativeFunctionPointerFromRawValue(long rawValue)` Creates a `NativeFunctionPointer` from a raw value.
`boolean` `isDefaultLibrarySearchSupported()` 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 the `LD_LIBRARY_PATH` environment variable.

#### getFunctionPointer

    NativeFunctionPointer getFunctionPointer(NativeLibraryHandle[] libraries,
                                           java.lang.String name)

Resolves the function pointer `NativeFunctionPointer` of a native function.

Parameters:
  `libraries` - the ordered list of libraries to search for the function
  `name` - 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,
                                         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 library
  `name` - the name of the function to be resolved
  `returnType` - the type of the return value
  `argumentTypes` - 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,
                                         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 pointer
  `returnType` - the type of the return value
  `argumentTypes` - 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,
                                         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 function
  `name` - the name of the function to be resolved
  `returnType` - the type of the return value
  `argumentTypes` - 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(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 resolved
  `returnType` - the type of the return value
  `argumentTypes` - 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

    NativeFunctionPointer getNativeFunctionPointerFromRawValue(long rawValue)

Creates a `NativeFunctionPointer` from a raw value.

Parameters:
  `rawValue` - raw function pointer
Returns:
  `NativeFunctionPointer` for `rawValue`