4444import java .util .logging .Level ;
4545import java .util .logging .Logger ;
4646
47+ import com .jme3 .system .NativeLibraries .LibraryInfo ;
4748import com .jme3 .util .res .Resources ;
4849
4950/**
@@ -94,6 +95,16 @@ public static void registerNativeLibrary(NativeLibrary library) {
9495 nativeLibraryMap .put (library .getKey (), library );
9596 }
9697
98+ /**
99+ * Register a new native library.
100+ *
101+ * This simply registers a known library, the actual extraction and loading is performed by calling
102+ * {@link #loadNativeLibrary(java.lang.String, boolean) }.
103+ */
104+ public static void registerNativeLibrary (LibraryInfo library ) {
105+ library .getNativeVariants ().forEach (NativeLibraryLoader ::registerNativeLibrary );
106+ }
107+
97108 /**
98109 * Register a new native library.
99110 *
@@ -428,11 +439,15 @@ public static void extractNativeLibrary(Platform platform, String name, File tar
428439 /**
429440 * First extracts the native library and then loads it.
430441 *
431- * @param name The name of the library to load.
432- * @param isRequired If true and the library fails to load, throw exception. If
433- * false, do nothing if it fails to load.
442+ * @param name
443+ * The name of the library to load.
444+ * @param isRequired
445+ * If true and the library fails to load, throw exception. If false, do nothing if it fails to
446+ * load.
447+ *
448+ * @return The absolute path of the loaded library.
434449 */
435- public static void loadNativeLibrary (String name , boolean isRequired ) {
450+ public static String loadNativeLibrary (String name , boolean isRequired ) {
436451 if (JmeSystem .isLowPermissions ()) {
437452 throw new UnsupportedOperationException ("JVM is running under "
438453 + "reduced permissions. Cannot load native libraries." );
@@ -453,15 +468,15 @@ public static void loadNativeLibrary(String name, boolean isRequired) {
453468 " is not available for your OS: {1}" ,
454469 new Object []{name , platform });
455470 }
456- return ;
471+ return null ;
457472 }
458473 }
459474
460475 final String pathInJar = library .getPathInNativesJar ();
461476
462477 if (pathInJar == null ) {
463478 // This platform does not require the native library to be loaded.
464- return ;
479+ return null ;
465480 }
466481
467482 URL url = Resources .getResource (pathInJar );
@@ -476,7 +491,7 @@ public static void loadNativeLibrary(String name, boolean isRequired) {
476491 " was not found in the classpath via ''{1}''." ,
477492 new Object []{library .getName (), pathInJar });
478493 }
479- return ;
494+ return null ;
480495 }
481496
482497 // The library has been found and is ready to be extracted.
@@ -526,6 +541,8 @@ public static void loadNativeLibrary(String name, boolean isRequired) {
526541 if (logger .isLoggable (Level .FINE )) {
527542 logger .log (Level .FINE , "Loaded native library {0}." , library .getName ());
528543 }
544+
545+ return targetFile .getAbsolutePath ();
529546 } catch (IOException ex ) {
530547 /*if (ex.getMessage().contains("used by another process")) {
531548 return;
0 commit comments