GeezerVison is showing github.com — NativeLibraryLoader: unfold loading code for easier reading. · mimoccc/objectbox-java@77a2b0b
File tree
Expand file treeCollapse file tree
Open diff view settings
objectbox-java/src/main/java/io/objectbox/internal
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: objectbox-java/src/main/java/io/objectbox/internal/NativeLibraryLoader.java +9-6Lines changed: 9 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -78,17 +78,21 @@ public class NativeLibraryLoader { |
78 | 78 | if (file.exists()) { |
79 | 79 | System.load(file.getAbsolutePath()); |
80 | 80 | } else { |
81 | | - if (!android) { |
82 | | - System.err.println("File not available: " + file.getAbsolutePath()); |
83 | | - } |
84 | 81 | try { |
85 | | - if (!android || !loadLibraryAndroid()) { // if android && loadLibraryAndroid OK: done |
| 82 | + if (android) { |
| 83 | + boolean success = loadLibraryAndroid(); |
| 84 | + if (!success) { |
| 85 | + System.loadLibrary(libname); |
| 86 | + } |
| 87 | + } else { |
| 88 | + System.err.println("File not available: " + file.getAbsolutePath()); |
86 | 89 | System.loadLibrary(libname); |
87 | 90 | } |
88 | 91 | } catch (UnsatisfiedLinkError e) { |
89 | 92 | if (!android && isLinux) { |
90 | 93 | // maybe is Android, but check failed: try loading Android lib |
91 | | - if (!loadLibraryAndroid()) { |
| 94 | + boolean success = loadLibraryAndroid(); |
| 95 | + if (!success) { |
92 | 96 | System.loadLibrary(OBJECTBOX_JNI); |
93 | 97 | } |
94 | 98 | } else { |
@@ -138,7 +142,6 @@ private static void checkUnpackLib(String filename) { |
138 | 142 | } |
139 | 143 | } |
140 | 144 |
|
141 | | - @SuppressWarnings("BooleanMethodIsAlwaysInverted") // more readable |
142 | 145 | private static boolean loadLibraryAndroid() { |
143 | 146 | if (BoxStore.context == null) { |
144 | 147 | return false; |
|