From 94fd9eaee76e862932dded6583a9c052e5aa9efc Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Thu, 24 Oct 2019 16:57:34 +0100 Subject: Use a different name for shared classloader namespace, to help debugging. Test: atest libnativeloader_test Bug: 130388701 Change-Id: I6dbb53cac7fb7ac8fb5178611a164c83c2ab59ba --- libnativeloader/library_namespaces.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libnativeloader/library_namespaces.cpp') diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index ef979591c0..03e0814211 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -56,6 +56,14 @@ constexpr const char* kNeuralNetworksNamespaceName = "neuralnetworks"; constexpr const char* kClassloaderNamespaceName = "classloader-namespace"; // Same thing for vendor APKs. constexpr const char* kVendorClassloaderNamespaceName = "vendor-classloader-namespace"; +// If the namespace is shared then add this suffix to form +// "classloader-namespace-shared" or "vendor-classloader-namespace-shared", +// respectively. A shared namespace (cf. ANDROID_NAMESPACE_TYPE_SHARED) has +// inherited all the libraries of the parent classloader namespace, or the +// platform namespace for the main app classloader. It is used to give full +// access to the platform libraries for apps bundled in the system image, +// including their later updates installed in /data. +constexpr const char* kSharedNamespaceSuffix = "-shared"; // (http://b/27588281) This is a workaround for apps using custom classloaders and calling // System.load() with an absolute path which is outside of the classloader library search path. @@ -161,7 +169,7 @@ Result LibraryNamespaces::Create(JNIEnv* env, uint32_t t "There is already a namespace associated with this classloader"); std::string system_exposed_libraries = default_public_libraries(); - const char* namespace_name = kClassloaderNamespaceName; + std::string namespace_name = kClassloaderNamespaceName; bool unbundled_vendor_or_product_app = false; if ((apk_origin == APK_ORIGIN_VENDOR || (apk_origin == APK_ORIGIN_PRODUCT && target_sdk_version > 29)) && @@ -204,6 +212,12 @@ Result LibraryNamespaces::Create(JNIEnv* env, uint32_t t } } + if (is_shared) { + // Show in the name that the namespace was created as shared, for debugging + // purposes. + namespace_name = namespace_name + kSharedNamespaceSuffix; + } + // Create the app namespace NativeLoaderNamespace* parent_ns = FindParentNamespaceByClassLoader(env, class_loader); // Heuristic: the first classloader with non-empty library_path is assumed to -- cgit v1.2.3