From df8148e8e855a5e5ef6de9de9d869d92a7db233e Mon Sep 17 00:00:00 2001 From: Nikolai Tillmann Date: Mon, 30 Sep 2024 21:25:47 -0700 Subject: [PATCH] loadLibraryUnsafe Summary: This new method works the same as `loadLibrary(...)`. Going forward, `loadLibrary(...)` should only get called with constants strings, while `loadLibraryUnsafe(...)` doesn't have that restriction. For all `loadLibrary(...)` calls, a tool like Redex can then determine which libraries are referenced by the application. Reviewed By: adicatana Differential Revision: D63471297 fbshipit-source-id: a3b6b53c3027ee056d9fcdf0303b886d0765a6f2 --- java/com/facebook/soloader/SoLoader.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/java/com/facebook/soloader/SoLoader.java b/java/com/facebook/soloader/SoLoader.java index d8b145a..216442f 100644 --- a/java/com/facebook/soloader/SoLoader.java +++ b/java/com/facebook/soloader/SoLoader.java @@ -808,10 +808,24 @@ public static SoSource[] cloneSoSources() { return null; } + // same as loadLibrary, but the given library-name must not be a string constant; as a result, a + // tool like Redex cannot determine which library is being referenced, possibly leading to the + // removal of any such indirectly referenced library. + public static boolean loadLibraryUnsafe(String shortName) { + return loadLibrary(shortName); + } + public static boolean loadLibrary(String shortName) { return isEnabled ? loadLibrary(shortName, 0) : NativeLoader.loadLibrary(shortName); } + // same as loadLibrary, but the given library-name must not be a string constant; as a result, a + // tool like Redex cannot determine which library is being referenced, possibly leading to the + // removal of any such indirectly referenced library. + public static boolean loadLibraryUnsafe(String shortName, int loadFlags) { + return loadLibrary(shortName, loadFlags); + } + /** * Load a shared library, initializing any JNI binding it contains. *