Skip to content

Commit

Permalink
Use correct native library on OpenJDK on AIX
Browse files Browse the repository at this point in the history
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.

java-native-access#1066
  • Loading branch information
matthiasblaesing committed Feb 14, 2019
1 parent e0d5537 commit 40c099a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/com/sun/jna/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 40c099a

Please sign in to comment.