diff options
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/java/java/lang/Runtime.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/luni/src/main/java/java/lang/Runtime.java b/luni/src/main/java/java/lang/Runtime.java index a3cb83e..73820dc 100644 --- a/luni/src/main/java/java/lang/Runtime.java +++ b/luni/src/main/java/java/lang/Runtime.java @@ -357,14 +357,11 @@ public class Runtime { */ void loadLibrary(String libraryName, ClassLoader loader) { if (loader != null) { + // TODO: We shouldn't assume that we know default linker search logic. String filename = loader.findLibrary(libraryName); if (filename == null) { - // It's not necessarily true that the ClassLoader used - // System.mapLibraryName, but the default setup does, and it's - // misleading to say we didn't find "libMyLibrary.so" when we - // actually searched for "liblibMyLibrary.so.so". - throw new UnsatisfiedLinkError(loader + " couldn't find \"" + - System.mapLibraryName(libraryName) + "\""); + // The dynamic linker might still find the library by name. + filename = System.mapLibraryName(libraryName); } String error = doLoad(filename, loader); if (error != null) { @@ -418,19 +415,23 @@ public class Runtime { // So, find out what the native library search path is for the ClassLoader in question... String ldLibraryPath = null; + String dexPath = null; if (loader != null && loader instanceof BaseDexClassLoader) { - ldLibraryPath = ((BaseDexClassLoader) loader).getLdLibraryPath(); + BaseDexClassLoader dexClassLoader = (BaseDexClassLoader) loader; + ldLibraryPath = dexClassLoader.getLdLibraryPath(); + dexPath = dexClassLoader.getDexPath(); } // nativeLoad should be synchronized so there's only one LD_LIBRARY_PATH in use regardless // of how many ClassLoaders are in the system, but dalvik doesn't support synchronized // internal natives. synchronized (this) { - return nativeLoad(name, loader, ldLibraryPath); + return nativeLoad(name, loader, ldLibraryPath, dexPath); } } // TODO: should be synchronized, but dalvik doesn't support synchronized internal natives. - private static native String nativeLoad(String filename, ClassLoader loader, String ldLibraryPath); + private static native String nativeLoad(String filename, ClassLoader loader, + String ldLibraryPath, String dexPath); /** * Provides a hint to the VM that it would be useful to attempt |