Subject: try to load native library from /usr/lib/jni if system
 property jna.boot.library.path is not set
Author: Jan Dittberner <jandd@debian.org>
--- libjna-java.orig/src/com/sun/jna/Native.java	2023-01-28 14:29:27.494569137 +0100
+++ libjna-java/src/com/sun/jna/Native.java	2023-01-28 14:29:27.486568833 +0100
@@ -952,6 +952,9 @@
 
         String libName = System.getProperty("jna.boot.library.name", "jnidispatch");
         String bootPath = System.getProperty("jna.boot.library.path");
+        if (bootPath == null) {
+            bootPath = "/usr/lib/jni" + File.pathSeparator + "/usr/lib/" + Platform.getMultiArchPath() + "/jni";
+        }
         if (bootPath != null) {
             // String.split not available in 1.4
             StringTokenizer dirs = new StringTokenizer(bootPath, File.pathSeparator);
--- libjna-java.orig/src/com/sun/jna/NativeLibrary.java	2023-01-28 14:29:27.494569137 +0100
+++ libjna-java/src/com/sun/jna/NativeLibrary.java	2023-01-28 14:29:27.486568833 +0100
@@ -944,7 +944,7 @@
             // so for platforms which are not multi-arch
             // this should continue to work.
             if (Platform.isLinux() || Platform.iskFreeBSD() || Platform.isGNU()) {
-                String multiArchPath = getMultiArchPath();
+                String multiArchPath = Platform.getMultiArchPath();
 
                 // Assemble path with all possible options
                 paths = new String[] {
@@ -990,30 +990,6 @@
         librarySearchPath.addAll(initPaths("jna.platform.library.path"));
     }
 
-    private static String getMultiArchPath() {
-        String cpu = Platform.ARCH;
-        String kernel = Platform.iskFreeBSD()
-            ? "-kfreebsd"
-            : (Platform.isGNU() ? "" : "-linux");
-        String libc = "-gnu";
-
-        if (Platform.isIntel()) {
-            cpu = (Platform.is64Bit() ? "x86_64" : "i386");
-        }
-        else if (Platform.isPPC()) {
-            cpu = (Platform.is64Bit() ? "powerpc64" : "powerpc");
-        }
-        else if (Platform.isARM()) {
-            cpu = "arm";
-            libc = "-gnueabi";
-        }
-        else if (Platform.ARCH.equals("mips64el")) {
-            libc = "-gnuabi64";
-        }
-
-        return cpu + kernel + libc;
-    }
-
     /**
      * Get the library paths from ldconfig cache. Tested against ldconfig 2.13.
      */
--- libjna-java.orig/src/com/sun/jna/Platform.java	2023-01-28 14:29:27.494569137 +0100
+++ libjna-java/src/com/sun/jna/Platform.java	2023-01-28 15:50:48.853325082 +0100
@@ -262,8 +262,12 @@
             arch = "ppc64le";
         }
         // Map arm to armel if the binary is running as softfloat build
-        if("arm".equals(arch) && platform == Platform.LINUX && isSoftFloat()) {
-            arch = "armel";
+        if("arm".equals(arch) && platform == Platform.LINUX ) {
+            if(isSoftFloat()) {
+                arch = "armel";
+            } else if(!is64Bit()) {
+                arch = "armhf";
+            }
         }
 
         return arch;
@@ -352,4 +356,30 @@
         }
         return osPrefix;
     }
+
+    public static String getMultiArchPath() {
+        String cpu = ARCH;
+        String kernel = iskFreeBSD()
+            ? "-kfreebsd"
+            : (isGNU() ? "" : "-linux");
+        String libc = "-gnu";
+
+        if (isIntel()) {
+            cpu = (is64Bit() ? "x86_64" : "i386");
+        }
+        else if (isPPC()) {
+            cpu = cpu.replace("ppc", "powerpc");
+        }
+        else if (isARM()) {
+            cpu = (is64Bit() ? "aarch64" : "arm");
+            libc = is64Bit()
+                ? "-gnu"
+                : ("armhf".equals(ARCH) ? "-gnueabihf" : "-gnueabi");
+        }
+        else if (ARCH.equals("mips64el")) {
+            libc = "-gnuabi64";
+        }
+
+        return cpu + kernel + libc;
+    }
 }
