Class LibraryResource


  • public final class LibraryResource
    extends java.lang.Object
    Handles loading of native resources in LWJGL. [INTERNAL USE ONLY]

    This class uses the same mechanism as Library for loading shared libraries. The resource name could be an absolute path, or a relative path that is resolved via org.lwjgl.librarypath, java.library.path, or even the class/module-path. When the resource is detected in the class/module-path, it is extracted automatically to org.lwjgl.librarypath via the SharedLibraryLoader.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.nio.file.Path load​(java.lang.Class<?> context, java.lang.String module, java.lang.String name)
      Loads a library resource.
      static java.nio.file.Path load​(java.lang.Class<?> context, java.lang.String module, java.lang.String name, boolean bundledWithLWJGL)
      Loads a library resource.
      static java.nio.file.Path load​(java.lang.Class<?> context, java.lang.String module, Configuration<java.lang.String> name, java.lang.String... defaultNames)
      Loads a library resource using load(String, String) with the name specified by name.
      static java.nio.file.Path load​(java.lang.Class<?> context, java.lang.String module, Configuration<java.lang.String> name, java.util.function.Supplier<java.nio.file.Path> fallback, java.lang.String... defaultNames)
      Loads a library resource using load with the name specified by name.
      static java.nio.file.Path load​(java.lang.String module, java.lang.String name)
      Calls load(Class, String, String) using LibraryResource.class as the context parameter.
      • Methods inherited from class java.lang.Object

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

      • load

        public static java.nio.file.Path load​(java.lang.String module,
                                              java.lang.String name)
        Calls load(Class, String, String) using LibraryResource.class as the context parameter.
      • load

        public static java.nio.file.Path load​(java.lang.Class<?> context,
                                              java.lang.String module,
                                              java.lang.String name)
        Loads a library resource.
        Parameters:
        context - the class to use to discover the library resource in the classpath
        module - the module to which the resource belongs
        name - the resource name
        Returns:
        the library resource path
        Throws:
        java.lang.IllegalStateException - if the resource could not be found
      • load

        public static java.nio.file.Path load​(java.lang.Class<?> context,
                                              java.lang.String module,
                                              java.lang.String name,
                                              boolean bundledWithLWJGL)
        Loads a library resource.
        Parameters:
        context - the class to use to discover the library resource in the classpath
        module - the module to which the resource belongs
        name - the resource name
        bundledWithLWJGL - whether the default LWJGL distribution includes the resource. If true, LWJGL will also try to find the shared library under the <platform>/<arch>/<module> subfolder.
        Returns:
        the library resource path
        Throws:
        java.lang.IllegalStateException - if the resource could not be found
      • load

        public static java.nio.file.Path load​(java.lang.Class<?> context,
                                              java.lang.String module,
                                              Configuration<java.lang.String> name,
                                              java.lang.String... defaultNames)
        Loads a library resource using load(String, String) with the name specified by name. If name is not set, load(String, String) will be called with the names specified by defaultNames. The first successful will be returned.
        Parameters:
        name - a Configuration that specifies the resource name
        defaultNames - the default resource name(s)
        Returns:
        the library resource path
        Throws:
        java.lang.IllegalStateException - if the resource could not be found
      • load

        public static java.nio.file.Path load​(java.lang.Class<?> context,
                                              java.lang.String module,
                                              Configuration<java.lang.String> name,
                                              @Nullable
                                              java.util.function.Supplier<java.nio.file.Path> fallback,
                                              java.lang.String... defaultNames)
        Loads a library resource using load with the name specified by name. If name is not set, load will be called with the names specified by defaultNames. The first successful will be returned. If the resource could not be found, the fallback will be called.
        Parameters:
        name - a Configuration that specifies the resource name
        fallback - fallback to use if everything else fails
        defaultNames - the default resource name(s)
        Returns:
        the library resource path
        Throws:
        java.lang.UnsatisfiedLinkError - if the resource could not be found