java: Special-case the arch-specific load to account for "x86_64"

0453438d added the capability to prefer arch-specific versions of
libsignal_jni, but it turns out that some Java implementations use
"x86_64" rather than the "amd64" we expected. Rather than doing
something clever and general, just handle this one special case. If
this happens again with "arm64" vs "aarch64", we can spend more time
on it then.
This commit is contained in:
Jordan Rose
2024-08-05 17:48:49 -07:00
parent 3c01c95616
commit ee552962b9
2 changed files with 12 additions and 2 deletions

View File

@@ -68,7 +68,12 @@ public final class Native {
* This method should only be called from a static initializer.
*/
static void loadLibrary(String name) throws IOException {
for (String suffix : new String[]{ "_" + System.getProperty("os.arch"), "" }) {
String arch = System.getProperty("os.arch");
// Special-case: some Java implementations use "x86_64", but OpenJDK uses "amd64".
if (arch == "x86_64") {
arch = "amd64";
}
for (String suffix : new String[]{ "_" + arch, "" }) {
final String libraryName = System.mapLibraryName(name + suffix);
try (InputStream in = Native.class.getResourceAsStream("/" + libraryName)) {
if (in != null) {

View File

@@ -68,7 +68,12 @@ public final class Native {
* This method should only be called from a static initializer.
*/
static void loadLibrary(String name) throws IOException {
for (String suffix : new String[]{ "_" + System.getProperty("os.arch"), "" }) {
String arch = System.getProperty("os.arch");
// Special-case: some Java implementations use "x86_64", but OpenJDK uses "amd64".
if (arch == "x86_64") {
arch = "amd64";
}
for (String suffix : new String[]{ "_" + arch, "" }) {
final String libraryName = System.mapLibraryName(name + suffix);
try (InputStream in = Native.class.getResourceAsStream("/" + libraryName)) {
if (in != null) {