Package org.lwjgl.system
Class Library
- java.lang.Object
-
- org.lwjgl.system.Library
-
public final class Library extends java.lang.ObjectInitializes the LWJGL shared library and handles loading additional shared libraries.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringJNI_LIBRARY_NAMEThe LWJGL shared library name.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidinitialize()Ensures that the LWJGL shared library has been loaded.static SharedLibraryloadNative(java.lang.Class<?> context, java.lang.String name)Loads a shared library using OS-specific APIs (e.g.static SharedLibraryloadNative(java.lang.Class<?> context, java.lang.String name, boolean bundledWithLWJGL)Loads a shared library using OS-specific APIs (e.g.static SharedLibraryloadNative(java.lang.Class<?> context, Configuration<java.lang.String> name, java.lang.String... defaultNames)Loads a shared library usingloadNative(String)with the name specified byname.static SharedLibraryloadNative(java.lang.Class<?> context, Configuration<java.lang.String> name, java.util.function.Supplier<SharedLibrary> fallback, java.lang.String... defaultNames)Loads a shared library usingloadNative(String)with the name specified byname.static SharedLibraryloadNative(java.lang.String name)CallsloadNative(Class, String)usingLibrary.classas the context parameter.static voidloadSystem(java.lang.String name)Loads a JNI shared library.static voidloadSystem(java.util.function.Consumer<java.lang.String> load, java.util.function.Consumer<java.lang.String> loadLibrary, java.lang.Class<?> context, java.lang.String name)Loads a JNI shared library.
-
-
-
Method Detail
-
initialize
public static void initialize()
Ensures that the LWJGL shared library has been loaded.
-
loadSystem
public static void loadSystem(java.lang.String name) throws java.lang.UnsatisfiedLinkErrorLoads a JNI shared library.- Parameters:
name- the library name. If not an absolute path, it must be the plain library name, without an OS specific prefix or file extension (e.g. GL, not libGL.so)- Throws:
java.lang.UnsatisfiedLinkError
-
loadSystem
public static void loadSystem(java.util.function.Consumer<java.lang.String> load, java.util.function.Consumer<java.lang.String> loadLibrary, java.lang.Class<?> context, java.lang.String name) throws java.lang.UnsatisfiedLinkErrorLoads a JNI shared library.- Parameters:
load- should be theSystem::loadexpression. This ensures thatSystem.loadhas the same caller as this method.loadLibrary- should be theSystem::loadLibraryexpression. This ensures thatSystem.loadLibraryhas the same caller as this method.context- the class to use to discover the shared library in the classpathname- the library name. If not an absolute path, it must be the plain library name, without an OS specific prefix or file extension (e.g. GL, not libGL.so)- Throws:
java.lang.UnsatisfiedLinkError- if the library could not be loaded
-
loadNative
public static SharedLibrary loadNative(java.lang.String name)
CallsloadNative(Class, String)usingLibrary.classas the context parameter.
-
loadNative
public static SharedLibrary loadNative(java.lang.Class<?> context, java.lang.String name)
Loads a shared library using OS-specific APIs (e.g.LoadLibraryordlopen).- Parameters:
context- the class to use to discover the shared library in the classpathname- the library name. OS-specific prefixes and file extensions are optional (e.g. both"GL"and"libGL.so.1"are valid on Linux)- Returns:
- the shared library
- Throws:
java.lang.UnsatisfiedLinkError- if the library could not be loaded
-
loadNative
public static SharedLibrary loadNative(java.lang.Class<?> context, java.lang.String name, boolean bundledWithLWJGL)
Loads a shared library using OS-specific APIs (e.g.LoadLibraryordlopen).- Parameters:
context- the class to use to discover the shared library in the classpathname- the library name. OS-specific prefixes and file extensions are optional (e.g. both"GL"and"libGL.so.1"are valid on Linux)bundledWithLWJGL- whether the default LWJGL distribution includes the shared library. This flag does not affect the shared library loading process.- Returns:
- the shared library
- Throws:
java.lang.UnsatisfiedLinkError- if the library could not be loaded
-
loadNative
public static SharedLibrary loadNative(java.lang.Class<?> context, Configuration<java.lang.String> name, java.lang.String... defaultNames)
Loads a shared library usingloadNative(String)with the name specified byname. Ifnameis not set,loadNative(String)will be called with the names specified bydefaultNames. The first successful will be returned.- Parameters:
name- aConfigurationthat specifies the library namedefaultNames- the default library name(s)- Returns:
- the shared library
- Throws:
java.lang.UnsatisfiedLinkError- if the library could not be loaded
-
loadNative
public static SharedLibrary loadNative(java.lang.Class<?> context, Configuration<java.lang.String> name, @Nullable java.util.function.Supplier<SharedLibrary> fallback, java.lang.String... defaultNames)
Loads a shared library usingloadNative(String)with the name specified byname. Ifnameis not set,loadNative(String)will be called with the names specified bydefaultNames. The first successful will be returned. If the library could not be loaded, thefallbackwill be called.- Parameters:
name- aConfigurationthat specifies the library namefallback- fallback to use if everything else failsdefaultNames- the default library name(s)- Returns:
- the shared library
- Throws:
java.lang.UnsatisfiedLinkError- if the library could not be loaded
-
-