Throw exception on System.loadLibrary fail (#3916)
This commit is contained in:
@@ -20,6 +20,7 @@ public abstract class LibraryLoader {
|
||||
private static volatile LibraryLoader loader = DEFAULT;
|
||||
|
||||
private static boolean loaded;
|
||||
private static boolean handleLoadError = false;
|
||||
|
||||
/**
|
||||
* Set the library loader that loads the shared library.
|
||||
@@ -30,10 +31,17 @@ public abstract class LibraryLoader {
|
||||
loader = libraryLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch UnsatisfiedLinkErrors on load
|
||||
*/
|
||||
public static void enableErrorHandling(boolean value) {
|
||||
handleLoadError = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads "libmaplibre.so" native shared library.
|
||||
* <p>
|
||||
* Catches UnsatisfiedLinkErrors and prints a warning to logcat.
|
||||
* Catches UnsatisfiedLinkErrors (if enabled) and prints a warning to logcat.
|
||||
* </p>
|
||||
*/
|
||||
public static synchronized void load() {
|
||||
@@ -47,6 +55,10 @@ public abstract class LibraryLoader {
|
||||
String message = "Failed to load native shared library.";
|
||||
Logger.e(TAG, message, error);
|
||||
MapStrictMode.strictModeViolation(message, error);
|
||||
|
||||
if (!handleLoadError) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user