Use android::base::Result in libnativeloader
Remove the out parameters for error messages using Result<T>.
Bug: 130388701
Test: libnativeloader_test
Change-Id: Idbaf391c183fb20d5e1d7c96f3a4ccbf9745b7e6
diff --git a/libnativeloader/library_namespaces.h b/libnativeloader/library_namespaces.h
index 6e9a190..e54bc0a 100644
--- a/libnativeloader/library_namespaces.h
+++ b/libnativeloader/library_namespaces.h
@@ -25,10 +25,13 @@
#include <list>
#include <string>
+#include <android-base/result.h>
#include <jni.h>
namespace android::nativeloader {
+using android::base::Result;
+
// LibraryNamespaces is a singleton object that manages NativeLoaderNamespace
// objects for an app process. Its main job is to create (and configure) a new
// NativeLoaderNamespace object for a Java ClassLoader, and to find an existing
@@ -46,13 +49,13 @@
namespaces_.clear();
initialized_ = false;
}
- NativeLoaderNamespace* Create(JNIEnv* env, uint32_t target_sdk_version, jobject class_loader,
- bool is_shared, jstring dex_path, jstring java_library_path,
- jstring java_permitted_path, std::string* error_msg);
+ Result<NativeLoaderNamespace*> Create(JNIEnv* env, uint32_t target_sdk_version,
+ jobject class_loader, bool is_shared, jstring dex_path,
+ jstring java_library_path, jstring java_permitted_path);
NativeLoaderNamespace* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader);
private:
- bool InitPublicNamespace(const char* library_path, std::string* error_msg);
+ Result<void> InitPublicNamespace(const char* library_path);
NativeLoaderNamespace* FindParentNamespaceByClassLoader(JNIEnv* env, jobject class_loader);
bool initialized_;