Skip to content

Commit

Permalink
loadLibraryUnsafe
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Oct 1, 2024
1 parent bc2503a commit df8148e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions java/com/facebook/soloader/SoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit df8148e

Please sign in to comment.