Class NativeLoader
- java.lang.Object
-
- com.facebook.soloader.nativeloader.NativeLoader
-
public class NativeLoader extends java.lang.ObjectFacade to load native libraries for android
-
-
Method Summary
Modifier and Type Method Description static java.lang.StringgetLibraryPath(java.lang.String shortName)Get the path of a loaded shared library.static intgetSoSourcesVersion()Get the version of the loader used.static voidinit(NativeLoaderDelegate delegate)Initializes native code loading for this app.static voidinitIfUninitialized(NativeLoaderDelegate delegate)Perform an initialization only ifNativeLoaderhas not already been initialized.static booleanisInitialized()Determine whetherNativeLoaderhas already been initialized.static booleanloadLibrary(java.lang.String shortName)static booleanloadLibrary(java.lang.String shortName, int flags)Load a shared library, initializing any JNI binding it contains.
-
-
-
Method Detail
-
loadLibrary
public static boolean loadLibrary(java.lang.String shortName)
-
loadLibrary
public static boolean loadLibrary(java.lang.String shortName, int flags)Load a shared library, initializing any JNI binding it contains. Depending upon underlying loader, behavior can be customized based on passed in flag- Parameters:
shortName- Name of library to find, without "lib" prefix or ".so" suffixflags- 0 for default behavior, otherwise NativeLoaderDelegate defines other behaviors.- Returns:
- Whether the library was loaded as a result of this call (true), or was already loaded through a previous call (false).
-
getLibraryPath
public static java.lang.String getLibraryPath(java.lang.String shortName) throws java.io.IOExceptionGet the path of a loaded shared library.- Parameters:
shortName- Name of library to find, without "lib" prefix or ".so" suffix- Returns:
- The path for the loaded library, null otherwise.
- Throws:
java.io.IOException- IOException
-
getSoSourcesVersion
public static int getSoSourcesVersion()
Get the version of the loader used.- Returns:
- The version number for the loader.
-
init
public static void init(NativeLoaderDelegate delegate)
Initializes native code loading for this app. Should be called only once, before any calls toloadLibrary(String).- Parameters:
delegate- Delegate to use for allloadLibrarycalls.
-
isInitialized
public static boolean isInitialized()
Determine whetherNativeLoaderhas already been initialized. This method should not normally be used, because initialization should be performed only once during app startup. However, libraries that want to provide a default initialization forNativeLoaderto hide its existence from the app can use this method to avoid re-initializing.- Returns:
- True if
init(NativeLoaderDelegate)has been called.
-
initIfUninitialized
public static void initIfUninitialized(NativeLoaderDelegate delegate)
Perform an initialization only ifNativeLoaderhas not already been initialized. This protects against race conditions where isInitialized and init are called by multiple threads and both threads end up trying to perform an initialization- Parameters:
delegate- the NativeLoaderDelegate
-
-