Skip to content

Commit 44d1d3f

Browse files
rogersimmonsrogersimmons
andauthored
Add JNA minimum version check (OpenHFT#104)
Co-authored-by: rogersimmons <[email protected]>
1 parent 75814b2 commit 44d1d3f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

affinity/src/main/java/net/openhft/affinity/Affinity.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package net.openhft.affinity;
1919

20+
import com.sun.jna.Native;
2021
import net.openhft.affinity.impl.*;
2122
import org.jetbrains.annotations.NotNull;
2223
import org.slf4j.Logger;
@@ -187,13 +188,21 @@ public static void setThreadId() {
187188
}
188189

189190
public static boolean isJNAAvailable() {
190-
if (JNAAvailable == null)
191-
try {
192-
Class.forName("com.sun.jna.Platform");
193-
JNAAvailable = true;
194-
} catch (ClassNotFoundException ignored) {
191+
if (JNAAvailable == null) {
192+
int majorVersion = Integer.parseInt(Native.VERSION.split("\\.")[0]);
193+
if(majorVersion < 5) {
194+
LOGGER.warn("Affinity library requires JNA version >= 5");
195195
JNAAvailable = false;
196196
}
197+
else {
198+
try {
199+
Class.forName("com.sun.jna.Platform");
200+
JNAAvailable = true;
201+
} catch (ClassNotFoundException ignored) {
202+
JNAAvailable = false;
203+
}
204+
}
205+
}
197206
return JNAAvailable;
198207
}
199208

0 commit comments

Comments
 (0)