From 017c8e195b8439aface005fc19105821bbdbb903 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 J9. J9 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 Closes: #1066 --- CHANGES.md | 1 + src/com/sun/jna/Native.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 374d2c9642..4ad228da18 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Bug Fixes --------- * [#1052](https://github.com/java-native-access/jna/pull/1052), [#1053](https://github.com/java-native-access/jna/issues/1053): WinXP compatibility for `c.s.j.p.win32.PdhUtil` - [@dbwiddis](https://github.com/dbwiddis). * [#1055](https://github.com/java-native-access/jna/pull/1055): Include `c.s.j.p.linux` in OSGi bundle. - [@dbwiddis](https://github.com/dbwiddis). +* [#1066](https://github.com/java-native-access/jna/issues/1066): On AIX OpenJDK differs from IBM J9 in the mapping of library names. While J9 maps jnidispatch to `libjnidispatch.a`, OpenJDK maps to `libjnidispatch.so`, which causes the native library extractor to fail. AIX is now hard-coded to `libjnidispatch.a` - [@matthiasblaesing](https://github.com/matthiasblaesing). Release 5.2.0 ============= diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java index eae060f627..43515799ff 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 J9 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) {