From 4b19195d6d7f40faeb4f0f96b2dbb4e53746a8a1 Mon Sep 17 00:00:00 2001 From: Mikhail Zhukov Date: Wed, 19 Jan 2022 17:52:22 +0300 Subject: [PATCH] #302 Fixed running snappy-java as OSGi bundle on Apple Silicon (M1 Pro) --- build.sbt | 3 ++- src/main/java/org/xerial/snappy/SnappyBundleActivator.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 1c4248fd..86a6c263 100644 --- a/build.sbt +++ b/build.sbt @@ -86,8 +86,9 @@ OsgiKeys.additionalHeaders := Map( "org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x64", "org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=amd64", "org/xerial/snappy/native/Windows/x86/snappyjava.dll;osname=win32;processor=x86", - "org/xerial/snappy/native/Mac/x86/libsnappyjava.dylib;osname=macosx;processor=x86", + "org/xerial/snappy/native/Mac/x86/libsnappyjava.jnilib;osname=macosx;processor=x86", "org/xerial/snappy/native/Mac/x86_64/libsnappyjava.dylib;osname=macosx;processor=x86-64", + "org/xerial/snappy/native/Mac/aarch64/libsnappyjava.dylib;osname=macosx;processor=aarch64", "org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x86-64", "org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x64", "org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=amd64", diff --git a/src/main/java/org/xerial/snappy/SnappyBundleActivator.java b/src/main/java/org/xerial/snappy/SnappyBundleActivator.java index dec838c1..cd9d0ab7 100755 --- a/src/main/java/org/xerial/snappy/SnappyBundleActivator.java +++ b/src/main/java/org/xerial/snappy/SnappyBundleActivator.java @@ -51,7 +51,9 @@ public void start(BundleContext context) throws Exception { String library = System.mapLibraryName(LIBRARY_NAME); - if (library.toLowerCase().endsWith(".dylib")) { + String osArch = System.getProperty("os.arch"); + + if (library.toLowerCase().endsWith(".dylib") && "x86".equals(osArch)) { // some MacOS JDK7+ vendors map to dylib instead of jnilib library = library.replace(".dylib", ".jnilib"); }