diff options
author | Dimitry Ivanov <dimitry@google.com> | 2016-05-02 10:43:16 -0700 |
---|---|---|
committer | Dimitry Ivanov <dimitry@google.com> | 2016-05-02 10:43:16 -0700 |
commit | be4ca3afc0636b314d676480156eb6977739dd00 (patch) | |
tree | 71f7f7218be57efc66ab91595cb27761844e39bc /libnativeloader | |
parent | 721c9ce4a55c13716f263dc7a9cbda92b349b4b7 (diff) | |
download | system_core-be4ca3afc0636b314d676480156eb6977739dd00.tar.gz system_core-be4ca3afc0636b314d676480156eb6977739dd00.tar.bz2 system_core-be4ca3afc0636b314d676480156eb6977739dd00.zip |
nativeloader: Add Reset capabilities
In the case when VM is restarted all weak references
from the old VM become invalid. In such event NativeLoader
needs to clear the list of classloaders from old VM.
Bug: http://b/28453840
Bug: http://b/28449304
Change-Id: I2268c1e21cf940c57ddc5f0312f56b71aa702134
Diffstat (limited to 'libnativeloader')
-rw-r--r-- | libnativeloader/include/nativeloader/native_loader.h | 3 | ||||
-rw-r--r-- | libnativeloader/native_loader.cpp | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libnativeloader/include/nativeloader/native_loader.h b/libnativeloader/include/nativeloader/native_loader.h index 1bd3b8f07..d606a760e 100644 --- a/libnativeloader/include/nativeloader/native_loader.h +++ b/libnativeloader/include/nativeloader/native_loader.h @@ -50,6 +50,9 @@ __attribute__((visibility("default"))) android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader); #endif +__attribute__((visibility("default"))) +void ResetNativeLoader(); + }; // namespace android #endif // NATIVE_BRIDGE_H_ diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index 665b5b5b0..baad197fe 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -131,6 +131,10 @@ class LibraryNamespaces { public_libraries_ = base::Join(sonames, ':'); } + void Reset() { + namespaces_.clear(); + } + private: bool ReadConfig(const std::string& configFile, std::vector<std::string>* sonames) { // Read list of public native libraries from the config file. @@ -185,6 +189,12 @@ void InitializeNativeLoader() { #endif } +void ResetNativeLoader() { +#if defined(__ANDROID__) + std::lock_guard<std::mutex> guard(g_namespaces_mutex); + g_namespaces->Reset(); +#endif +} jstring CreateClassLoaderNamespace(JNIEnv* env, int32_t target_sdk_version, |