Skip to content

Commit 77a2b0b

Browse files
NativeLibraryLoader: unfold loading code for easier reading.
1 parent 798c365 commit 77a2b0b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

objectbox-java/src/main/java/io/objectbox/internal/NativeLibraryLoader.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,21 @@ public class NativeLibraryLoader {
7878
if (file.exists()) {
7979
System.load(file.getAbsolutePath());
8080
} else {
81-
if (!android) {
82-
System.err.println("File not available: " + file.getAbsolutePath());
83-
}
8481
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());
8689
System.loadLibrary(libname);
8790
}
8891
} catch (UnsatisfiedLinkError e) {
8992
if (!android && isLinux) {
9093
// maybe is Android, but check failed: try loading Android lib
91-
if (!loadLibraryAndroid()) {
94+
boolean success = loadLibraryAndroid();
95+
if (!success) {
9296
System.loadLibrary(OBJECTBOX_JNI);
9397
}
9498
} else {
@@ -138,7 +142,6 @@ private static void checkUnpackLib(String filename) {
138142
}
139143
}
140144

141-
@SuppressWarnings("BooleanMethodIsAlwaysInverted") // more readable
142145
private static boolean loadLibraryAndroid() {
143146
if (BoxStore.context == null) {
144147
return false;

0 commit comments

Comments
 (0)