From 911472da85bb1caa3e28d86c17ade347d06f33b3 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Mon, 2 May 2016 10:43:16 -0700 Subject: 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 (cherry picked from commit be4ca3afc0636b314d676480156eb6977739dd00) --- libnativeloader/native_loader.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libnativeloader/native_loader.cpp') diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index e20c82303..72152e737 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -121,6 +121,10 @@ class LibraryNamespaces { public_libraries_ = base::Join(sonames, ':'); } + void Reset() { + namespaces_.clear(); + } + private: bool ReadConfig(const std::string& configFile, std::vector* sonames) { // Read list of public native libraries from the config file. @@ -172,6 +176,12 @@ void InitializeNativeLoader() { #endif } +void ResetNativeLoader() { +#if defined(__ANDROID__) + std::lock_guard guard(g_namespaces_mutex); + g_namespaces->Reset(); +#endif +} jstring CreateClassLoaderNamespace(JNIEnv* env, int32_t target_sdk_version, -- cgit v1.2.3