From 40c099a8abb4090d8dd8acd34b023758b5d630bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Thu, 14 Feb 2019 23:07:23 +0100 Subject: [PATCH] Use correct native library on OpenJDK on AIX It seems System#mapLibraryName from OpenJDK works differently on AIX than OpenJ9. OpenJ9 expands jnidispatch to libjnidispatch.a, while OpenJDK expands it to libjnidispatch.so. This in turn causes the loader to search for the wrong file. https://github.com/java-native-access/jna/issues/1066 --- src/com/sun/jna/Native.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java index eae060f627..b503cf4ae9 100644 --- a/src/com/sun/jna/Native.java +++ b/src/com/sun/jna/Native.java @@ -999,7 +999,13 @@ private static void loadNativeDispatchLibrary() { */ private static void loadNativeDispatchLibraryFromClasspath() { try { - String libName = "/com/sun/jna/" + Platform.RESOURCE_PREFIX + "/" + System.mapLibraryName("jnidispatch").replace(".dylib", ".jnilib"); + String mappedName = System.mapLibraryName("jnidispatch").replace(".dylib", ".jnilib"); + if(Platform.isAIX()) { + // OpenJDK is reported to map to .so -- this works around the + // difference between OpenJ9 and OpenJDK + mappedName = "libjnidispatch.a"; + } + String libName = "/com/sun/jna/" + Platform.RESOURCE_PREFIX + "/" + mappedName; File lib = extractFromResourcePath(libName, Native.class.getClassLoader()); if (lib == null) { if (lib == null) {