diff options
| author | 2015-12-11 12:37:43 -0800 | |
|---|---|---|
| committer | 2015-12-11 12:37:43 -0800 | |
| commit | 1b6dd57975aefbb28d66f0e58ecdf4abe56648b4 (patch) | |
| tree | ed8a1ce97cca924207da598fe7333c4ae7083f77 /runtime/native/java_lang_Runtime.cc | |
| parent | 4b273683dcc6087e70e1e4f98867c55aebed6f61 (diff) | |
| parent | 98d46d2d287c8081995517770392a21b4d59d2e9 (diff) | |
Merge "Use isolated namespaces for app native libs"
am: 98d46d2d28
* commit '98d46d2d287c8081995517770392a21b4d59d2e9':
Use isolated namespaces for app native libs
Diffstat (limited to 'runtime/native/java_lang_Runtime.cc')
| -rw-r--r-- | runtime/native/java_lang_Runtime.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/runtime/native/java_lang_Runtime.cc b/runtime/native/java_lang_Runtime.cc index 856a3e7d01..ff82772171 100644 --- a/runtime/native/java_lang_Runtime.cc +++ b/runtime/native/java_lang_Runtime.cc @@ -52,10 +52,10 @@ NO_RETURN static void Runtime_nativeExit(JNIEnv*, jclass, jint status) { exit(status); } -static void SetLdLibraryPath(JNIEnv* env, jstring javaLdLibraryPathJstr) { +static void SetLdLibraryPath(JNIEnv* env, jstring javaLdLibraryPath) { #ifdef __ANDROID__ - if (javaLdLibraryPathJstr != nullptr) { - ScopedUtfChars ldLibraryPath(env, javaLdLibraryPathJstr); + if (javaLdLibraryPath != nullptr) { + ScopedUtfChars ldLibraryPath(env, javaLdLibraryPath); if (ldLibraryPath.c_str() != nullptr) { android_update_LD_LIBRARY_PATH(ldLibraryPath.c_str()); } @@ -63,23 +63,31 @@ static void SetLdLibraryPath(JNIEnv* env, jstring javaLdLibraryPathJstr) { #else LOG(WARNING) << "android_update_LD_LIBRARY_PATH not found; .so dependencies will not work!"; - UNUSED(javaLdLibraryPathJstr, env); + UNUSED(javaLdLibraryPath, env); #endif } static jstring Runtime_nativeLoad(JNIEnv* env, jclass, jstring javaFilename, jobject javaLoader, - jstring javaLdLibraryPathJstr) { + jstring javaLdLibraryPath, jstring javaIsolationPath) { ScopedUtfChars filename(env, javaFilename); if (filename.c_str() == nullptr) { return nullptr; } - SetLdLibraryPath(env, javaLdLibraryPathJstr); + int32_t target_sdk_version = Runtime::Current()->GetTargetSdkVersion(); + + // Starting with N nativeLoad uses classloader local + // linker namespace instead of global LD_LIBRARY_PATH + // (23 is Marshmallow) + if (target_sdk_version == 0) { + SetLdLibraryPath(env, javaLdLibraryPath); + } std::string error_msg; { JavaVMExt* vm = Runtime::Current()->GetJavaVM(); - bool success = vm->LoadNativeLibrary(env, filename.c_str(), javaLoader, &error_msg); + bool success = vm->LoadNativeLibrary(env, filename.c_str(), javaLoader, + javaLdLibraryPath, javaIsolationPath, &error_msg); if (success) { return nullptr; } @@ -107,7 +115,7 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Runtime, gc, "()V"), NATIVE_METHOD(Runtime, maxMemory, "!()J"), NATIVE_METHOD(Runtime, nativeExit, "(I)V"), - NATIVE_METHOD(Runtime, nativeLoad, "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/String;"), + NATIVE_METHOD(Runtime, nativeLoad, "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"), NATIVE_METHOD(Runtime, totalMemory, "!()J"), }; |