From bbf413d48d392a00e9bbc7ae4e00fb39f91c1170 Mon Sep 17 00:00:00 2001 From: "chip@chipfraser.co.uk" Date: Mon, 27 Nov 2017 14:01:12 +0000 Subject: [PATCH] Make code compatible with jna 3.5.2 as well as 4.4.0 --- .../openhft/chronicle/hash/impl/util/jna/PosixMsync.java | 9 ++++----- .../chronicle/hash/impl/util/jna/WindowsMsync.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixMsync.java b/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixMsync.java index ecb7b0d13..45a79c476 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixMsync.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixMsync.java @@ -17,10 +17,8 @@ package net.openhft.chronicle.hash.impl.util.jna; -import com.sun.jna.IntegerType; -import com.sun.jna.Native; -import com.sun.jna.Platform; -import com.sun.jna.Pointer; +import com.sun.jna.*; +import net.openhft.chronicle.core.OS; import java.io.IOException; @@ -36,7 +34,8 @@ public final class PosixMsync { private static native int msync(Pointer addr, size_t length, int flags); static { - Native.register(PosixMsync.class, Platform.C_LIBRARY_NAME); + NativeLibrary clib = NativeLibrary.getInstance(Platform.C_LIBRARY_NAME); + Native.register(PosixMsync.class, clib); } private PosixMsync() {} diff --git a/src/main/java/net/openhft/chronicle/hash/impl/util/jna/WindowsMsync.java b/src/main/java/net/openhft/chronicle/hash/impl/util/jna/WindowsMsync.java index 846a9dbbb..f771268dc 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/util/jna/WindowsMsync.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/util/jna/WindowsMsync.java @@ -50,7 +50,7 @@ public final class WindowsMsync { // Finally calls FlushFileBuffers raf.getChannel().force(false); } else { - throw new IOException(Kernel32Util.formatMessage(lastError)); + throw new IOException(Kernel32Util.formatMessageFromLastErrorCode(lastError)); } }