Example usage
public interface LibC {
int puts(String str);
}
LibC libc = LibraryLoader.create(LibC.class).load("c");
libc.puts("Hello, World");
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | |
| private boolean | |
| private final FunctionMapper. | |
| private final List | |
| private final Class | |
| private final List | |
| private final Map | |
| private final List | |
| private final TypeMapper. | |
| private final List |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public LibraryLoader | Returns: TheLibraryLoader instance.The calling convention. convention)Sets the native function calling convention. |
| public static < The library type. T> LibraryLoader | |
| private T | |
| public final LibraryLoader | |
| private static List | |
| private Collection | |
| public LibraryLoader | |
| public T | Returns: an implementation of the interface provided tocreate(Class) that will call the native methods.The name or path of library to load. libraryName)Loads a native library and links the methods defined in |
| public T | Returns: an implementation of the interface provided tocreate(Class) that will call the native methods.Loads a native library and links the methods defined in |
| public static < the interface type. T> T | Returns: an instance ofinterfaceclass that will call the native methods.the interface that describes the native library interface interfaceClass, Map<LibraryOption, ?> options libraryOptions, Map<String, List<String>> a map of library names to paths that should be searched searchPaths, String... the name of the library to load libraryNames)Loads a native library and links the methods defined in |
| public static < the interface type T> T | Returns: a new object implementing the interface and bound to the librarythe interface to implement interfaceClass, Map<LibraryOption, ?> options libraryOptions, String... names to try when searching for the library libraryNames)Same as calling |
| protected abstract T | Returns: an instance ofinterfaceClass that will call the native methods.The java class that describes the functions to be mapped. interfaceClass, Collection<String> A list of libraries to load and search for symbols. libraryNames, Collection<String> The paths to search for libraries to be loaded. searchPaths, Map<LibraryOption, Object> The options to apply when loading the library. options, boolean whether to fast-fail when the library does not implement the requested functions failImmediately)Implemented by FFI providers to load the actual library. |
| public < The Java type. J> LibraryLoader | Returns: TheLibraryLoader instance.The java type to convert to a native type. javaType, ToNativeConverter<? extends J, ?> A toNativeConverter)jnr. that will convert from the java type to a native type.Adds a custom java type mapping. |
| public < The Java type. J> LibraryLoader | Returns: TheLibraryLoader instance.The java type to convert to a native type. javaType, FromNativeConverter<? extends J, ?> A fromNativeConverter)jnr. that will convert from the native type to a java type.Adds a custom java type mapping. |
| public <J> LibraryLoader | |
| public LibraryLoader | |
| public LibraryLoader | Returns: TheLibraryLoader instance.The type mapper to use. typeMapper)Adds a type mapper to use when resolving method parameter and result types. |
| public LibraryLoader | Returns: TheLibraryLoader instance.The type mapper to use. typeMapper)Adds a type mapper to use when resolving method parameter and result types. |
| public LibraryLoader | Returns: TheLibraryLoader instance.The function mapper to use. functionMapper)Adds a function mapper to use when resolving symbols in this library. |
| public LibraryLoader | Returns: TheLibraryLoader instance.The option to set. option, Object The value for the option. value)Sets an option when loading libraries. |
| public static boolean | Returns: true if the error was saved, false otherwiseoptions options, boolean whether the method has error-saving enabled methodHasSave, boolean whether the method ignores errors methodHasIgnore)When either the
| none | SL | IL | SL+IL|
-------------------------------------
none | save | save | ignr | save |
SM | save | save | save | save |
IM | ignr | ignr | ignr | ignr |
SM + IM | save | save | save | save |
|
| public LibraryLoader | |
| public LibraryLoader | |
| public final LibraryLoader | Returns: ThisLibraryLoader instance.Sets the calling convention of the library to the Windows stdcall calling convention |
| DEFAULT_LIBRARY | back to summary |
|---|---|
| public static final String DEFAULT_LIBRARY | |
| failImmediately | back to summary |
|---|---|
| private boolean failImmediately | |
| functionMapperBuilder | back to summary |
|---|---|
| private final FunctionMapper. | |
| functionMappers | back to summary |
|---|---|
| private final List<FunctionMapper> functionMappers | |
| interfaceClass | back to summary |
|---|---|
| private final Class<T> interfaceClass | |
| libraryNames | back to summary |
|---|---|
| private final List<String> libraryNames | |
| optionMap | back to summary |
|---|---|
| private final Map<LibraryOption, Object> optionMap | |
| searchPaths | back to summary |
|---|---|
| private final List<String> searchPaths | |
| typeMapperBuilder | back to summary |
|---|---|
| private final TypeMapper. | |
| typeMappers | back to summary |
|---|---|
| private final List<SignatureTypeMapper> typeMappers | |
| LibraryLoader | back to summary |
|---|---|
| protected LibraryLoader(Class<T> interfaceClass) | |
| convention | back to summary |
|---|---|
| public LibraryLoader Sets the native function calling convention. This is only needed on windows platforms - unless explicitly specified, all platforms assume
| |
| create | back to summary |
|---|---|
| public static <T> LibraryLoader Creates a new
| |
| createErrorProxy | back to summary |
|---|---|
| private T createErrorProxy(final Throwable ex) | |
| failImmediately | back to summary |
|---|---|
| public final LibraryLoader Turns off lazy propagation of load failures. By default,
| |
| getPropertyPaths | back to summary |
|---|---|
| private static List | |
| getSearchPaths | back to summary |
|---|---|
| private Collection | |
| library | back to summary |
|---|---|
| public LibraryLoader Adds a library to be loaded. Multiple libraries can be specified using additional calls to this method, and all libraries will be searched to resolve symbols (e.g. functions, variables).
| |
| load | back to summary |
|---|---|
| public T load(String libraryName) Loads a native library and links the methods defined in
| |
| load | back to summary |
|---|---|
| public T load() Loads a native library and links the methods defined in
| |
| loadLibrary | back to summary |
|---|---|
| public static <T> T loadLibrary(Class<T> interfaceClass, Map<LibraryOption, ?> libraryOptions, Map<String, List<String>> searchPaths, String... libraryNames) Loads a native library and links the methods defined in
| |
| loadLibrary | back to summary |
|---|---|
| public static <T> T loadLibrary(Class<T> interfaceClass, Map<LibraryOption, ?> libraryOptions, String... libraryNames) Same as calling
| |
| loadLibrary | back to summary |
|---|---|
| protected abstract T loadLibrary(Class<T> interfaceClass, Collection<String> libraryNames, Collection<String> searchPaths, Map<LibraryOption, Object> options, boolean failImmediately) Implemented by FFI providers to load the actual library.
| |
| map | back to summary |
|---|---|
| public <J> LibraryLoader Adds a custom java type mapping.
| |
| map | back to summary |
|---|---|
| public <J> LibraryLoader Adds a custom java type mapping.
| |
| map | back to summary |
|---|---|
| public <J> LibraryLoader | |
| map | back to summary |
|---|---|
| public LibraryLoader Adds a function name mapping to use when resolving symbols in this library.
| |
| mapper | back to summary |
|---|---|
| public LibraryLoader Adds a type mapper to use when resolving method parameter and result types. Multiple type mappers can be specified by additional calls to this method, and each mapper will be tried in order until one is successful.
| |
| mapper | back to summary |
|---|---|
| public LibraryLoader Adds a type mapper to use when resolving method parameter and result types. Multiple type mappers can be specified by additional calls to this method, and each mapper will be tried in order until one is successful.
| |
| mapper | back to summary |
|---|---|
| public LibraryLoader Adds a function mapper to use when resolving symbols in this library. Multiple function mappers can be specified by additional calls to this method, and each mapper will be tried in order, until one is successful.
| |
| option | back to summary |
|---|---|
| public LibraryLoader Sets an option when loading libraries.
| |
| saveError | back to summary |
|---|---|
| public static boolean saveError(Map<LibraryOption, ?> options, boolean methodHasSave, boolean methodHasIgnore) When either the
| none | SL | IL | SL+IL|
-------------------------------------
none | save | save | ignr | save |
SM | save | save | save | save |
IM | ignr | ignr | ignr | ignr |
SM + IM | save | save | save | save |
| |
| search | back to summary |
|---|---|
| public LibraryLoader Adds a path to search for libraries. Multiple paths can be specified using multiple calls to this method, and all paths will be searched..
| |
| searchDefault | back to summary |
|---|---|
| public LibraryLoader Add the default library to the search order. This will search all loaded libraries in the current process according to the system's implementation of dlsym(RTLD_DEFAULT).
| |
| stdcall | back to summary |
|---|---|
| public final LibraryLoader Sets the calling convention of the library to the Windows stdcall calling convention
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static void |
| PATHS | back to summary |
|---|---|
| pack-priv static final List<String> PATHS | |
| DefaultLibPaths | back to summary |
|---|---|
| pack-priv DefaultLibPaths() | |
| addPathsFromFile | back to summary |
|---|---|
| private static void addPathsFromFile(Collection<String> paths, File file) | |