From f3308493f7dc6ded84588cd9e6c579aea33aece1 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 14 May 2019 18:49:58 +0700 Subject: [PATCH] Ensure JNA 4.x compatibility (i.e. use JNA package on Linux) --- source/net/filebot/mediainfo/MediaInfoLibrary.java | 5 +++++ source/net/filebot/platform/gnome/NativeGVFS.java | 2 ++ source/net/filebot/platform/mac/xattr/XAttr.java | 3 +-- source/net/filebot/platform/windows/Kernel32.java | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/net/filebot/mediainfo/MediaInfoLibrary.java b/source/net/filebot/mediainfo/MediaInfoLibrary.java index fd236808..3c90bf17 100644 --- a/source/net/filebot/mediainfo/MediaInfoLibrary.java +++ b/source/net/filebot/mediainfo/MediaInfoLibrary.java @@ -16,8 +16,13 @@ interface MediaInfoLibrary extends Library { // libmediainfo for linux depends on libzen, so we need to load dependencies first, because we know where our native libs are (e.g. Java Web Start Cache). // if we do not, the system will look for dependencies, but only in the library path + + // Ensure JNA 4.x compatibility (i.e. use JNA package on Linux) + @SuppressWarnings("deprecation") Library LIB_ZEN = Platform.isLinux() ? (Library) Native.loadLibrary("zen", Library.class) : null; + // Ensure JNA 4.x compatibility (i.e. use JNA package on Linux) + @SuppressWarnings("deprecation") MediaInfoLibrary INSTANCE = (MediaInfoLibrary) Native.loadLibrary("mediainfo", MediaInfoLibrary.class, singletonMap(OPTION_FUNCTION_MAPPER, new FunctionMapper() { @Override diff --git a/source/net/filebot/platform/gnome/NativeGVFS.java b/source/net/filebot/platform/gnome/NativeGVFS.java index fc56ede4..0d9bb51b 100644 --- a/source/net/filebot/platform/gnome/NativeGVFS.java +++ b/source/net/filebot/platform/gnome/NativeGVFS.java @@ -8,6 +8,8 @@ import com.sun.jna.Pointer; public class NativeGVFS implements GVFS { + // Ensure JNA 4.x compatibility (i.e. use JNA package on Linux) + @SuppressWarnings("deprecation") private static final LibGIO lib_gio = (LibGIO) Native.loadLibrary("gio-2.0", LibGIO.class); private static final Pointer gvfs = lib_gio.g_vfs_get_default(); diff --git a/source/net/filebot/platform/mac/xattr/XAttr.java b/source/net/filebot/platform/mac/xattr/XAttr.java index 91d149d8..7d2eae2d 100644 --- a/source/net/filebot/platform/mac/xattr/XAttr.java +++ b/source/net/filebot/platform/mac/xattr/XAttr.java @@ -6,8 +6,7 @@ import com.sun.jna.Pointer; public interface XAttr extends Library { - // load from current image - XAttr INSTANCE = Native.loadLibrary(null, XAttr.class); + XAttr INSTANCE = Native.load(null, XAttr.class); // see /usr/include/sys/xattr.h int XATTR_NOFOLLOW = 0x0001; diff --git a/source/net/filebot/platform/windows/Kernel32.java b/source/net/filebot/platform/windows/Kernel32.java index 5fee71d9..630d932e 100644 --- a/source/net/filebot/platform/windows/Kernel32.java +++ b/source/net/filebot/platform/windows/Kernel32.java @@ -9,7 +9,7 @@ import com.sun.jna.win32.W32APIOptions; public interface Kernel32 extends StdCallLibrary { - Kernel32 INSTANCE = Native.loadLibrary("kernel32", Kernel32.class, W32APIOptions.DEFAULT_OPTIONS); + Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class, W32APIOptions.DEFAULT_OPTIONS); long APPMODEL_ERROR_NO_PACKAGE = 15700; long ERROR_INSUFFICIENT_BUFFER = 122;