Class Library

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String JNI_LIBRARY_NAME
      The LWJGL shared library name.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void initialize()
      Ensures that the LWJGL shared library has been loaded.
      static SharedLibrary loadNative​(java.lang.Class<?> context, java.lang.String module, java.lang.String name)
      Loads a shared library using OS-specific APIs (e.g.
      static SharedLibrary loadNative​(java.lang.Class<?> context, java.lang.String module, java.lang.String name, boolean bundledWithLWJGL)
      Loads a shared library using OS-specific APIs (e.g.
      static SharedLibrary loadNative​(java.lang.Class<?> context, java.lang.String module, Configuration<java.lang.String> name, java.lang.String... defaultNames)
      Loads a shared library using loadNative(String, String) with the name specified by name.
      static SharedLibrary loadNative​(java.lang.Class<?> context, java.lang.String module, Configuration<java.lang.String> name, java.util.function.Supplier<SharedLibrary> fallback, java.lang.String... defaultNames)
      Loads a shared library using loadNative(String, String) with the name specified by name.
      static SharedLibrary loadNative​(java.lang.String module, java.lang.String name)
      Calls loadNative(Class, String, String) using Library.class as the context parameter.
      static void loadSystem​(java.lang.String module, java.lang.String name)
      Calls loadSystem(Consumer, Consumer, Class, String, String) using Library.class as the context parameter.
      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 module, java.lang.String name)
      Loads a JNI shared library.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JNI_LIBRARY_NAME

        public static final java.lang.String JNI_LIBRARY_NAME
        The LWJGL shared library name.
    • Method Detail

      • initialize

        public static void initialize()
        Ensures that the LWJGL shared library has been loaded.
      • loadSystem

        public static void loadSystem​(java.lang.String module,
                                      java.lang.String name)
                               throws java.lang.UnsatisfiedLinkError
        Calls loadSystem(Consumer, Consumer, Class, String, String) using Library.class as the context parameter.
        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 module,
                                      java.lang.String name)
                               throws java.lang.UnsatisfiedLinkError
        Loads a JNI shared library.
        Parameters:
        load - should be the System::load expression. This ensures that System.load has the same caller as this method.
        loadLibrary - should be the System::loadLibrary expression. This ensures that System.loadLibrary has the same caller as this method.
        context - the class to use to discover the shared library in the classpath
        module - the module to which the shared library belongs
        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 - if the library could not be loaded
      • loadNative

        public static SharedLibrary loadNative​(java.lang.Class<?> context,
                                               java.lang.String module,
                                               java.lang.String name)
        Loads a shared library using OS-specific APIs (e.g. LoadLibrary or dlopen).
        Parameters:
        context - the class to use to discover the shared library in the classpath
        module - the module to which the shared library belongs
        name - 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 module,
                                               java.lang.String name,
                                               boolean bundledWithLWJGL)
        Loads a shared library using OS-specific APIs (e.g. LoadLibrary or dlopen).
        Parameters:
        context - the class to use to discover the shared library in the classpath
        module - the module to which the shared library belongs
        name - 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. If true, LWJGL will also try to find the shared library under the <platform>/<arch>/<module> subfolder.
        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 module,
                                               @Nullable
                                               Configuration<java.lang.String> name,
                                               java.lang.String... defaultNames)
        Loads a shared library using loadNative(String, String) with the name specified by name. If name is not set, loadNative(String, String) will be called with the names specified by defaultNames. The first successful will be returned.
        Parameters:
        name - a Configuration that specifies the library name
        defaultNames - 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,
                                               java.lang.String module,
                                               @Nullable
                                               Configuration<java.lang.String> name,
                                               @Nullable
                                               java.util.function.Supplier<SharedLibrary> fallback,
                                               java.lang.String... defaultNames)
        Loads a shared library using loadNative(String, String) with the name specified by name. If name is not set, loadNative(String, String) will be called with the names specified by defaultNames. The first successful will be returned. If the library could not be loaded, the fallback will be called.
        Parameters:
        name - a Configuration that specifies the library name
        fallback - fallback to use if everything else fails
        defaultNames - the default library name(s)
        Returns:
        the shared library
        Throws:
        java.lang.UnsatisfiedLinkError - if the library could not be loaded