diff --git a/.gitignore b/.gitignore
index a427da3..d327337 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
# IntelliJ
.idea
.idea_modules
+*.iml
# sbt specific
bin/.lib
diff --git a/pom.xml b/pom.xml
index 2e676e8..c224902 100755
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
org.xerial.snappy
snappy-java
- 1.0.5-M2
+ 1.0.5-M3-SNAPSHOT
Snappy for Java
snappy-java: A fast compression/decompression library
bundle
diff --git a/src/main/java/org/xerial/snappy/OSInfo.java b/src/main/java/org/xerial/snappy/OSInfo.java
index 95682fa..4ec6686 100755
--- a/src/main/java/org/xerial/snappy/OSInfo.java
+++ b/src/main/java/org/xerial/snappy/OSInfo.java
@@ -78,9 +78,9 @@ public class OSInfo
// ignored: fall back to "arm" arch (soft-float ABI)
}
}
- else if(getOSName().equals("Mac") && osArch.equals("universal")) {
- return "x86_64"; // Fix for openjdk7
- }
+ else if(getOSName().equals("Mac") && (osArch.equals("universal") || osArch.equals("amd64"))) {
+ return "x86_64"; // Fix for openjdk7
+ }
return translateArchNameToFolderName(osArch);
}
diff --git a/src/main/java/org/xerial/snappy/SnappyLoader.java b/src/main/java/org/xerial/snappy/SnappyLoader.java
index 4a33396..9ec625f 100755
--- a/src/main/java/org/xerial/snappy/SnappyLoader.java
+++ b/src/main/java/org/xerial/snappy/SnappyLoader.java
@@ -24,13 +24,7 @@
//--------------------------------------
package org.xerial.snappy;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
@@ -411,13 +405,10 @@ public class SnappyLoader
static File findNativeLibrary() {
boolean useSystemLib = Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_USE_SYSTEMLIB, "false"));
- if (useSystemLib)
- return null;
-
boolean disabledBundledLibs = Boolean
.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_BUNDLED_LIBS, "false"));
- if (disabledBundledLibs)
- return null;
+ if (useSystemLib || disabledBundledLibs)
+ return null; // Use a pre-installed libsnappyjava
// Try to load the library in org.xerial.snappy.lib.path */
String snappyNativeLibraryPath = System.getProperty(KEY_SNAPPY_LIB_PATH);
@@ -433,23 +424,43 @@ public class SnappyLoader
return nativeLib;
}
- {
- // Load an OS-dependent native library inside a jar file
- snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
- if (SnappyLoader.class.getResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName) != null) {
- // Temporary library folder. Use the value of org.xerial.snappy.tempdir or java.io.tmpdir
- String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR,
- System.getProperty("java.io.tmpdir"))).getAbsolutePath();
-
- // Extract and load a native library inside the jar file
- return extractLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder);
+ // Load an OS-dependent native library inside a jar file
+ snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
+ boolean hasNativeLib = hasResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName);
+ if(!hasNativeLib) {
+ if(OSInfo.getOSName().equals("Mac")) {
+ // Fix for openjdk7 for Mac
+ String altName = "libsnappyjava.jnilib";
+ if(hasResource(snappyNativeLibraryPath + "/" + altName)) {
+ snappyNativeLibraryName = altName;
+ hasNativeLib = true;
+ }
}
}
- return null; // Use a pre-installed libsnappyjava
+ if(!hasNativeLib) {
+ String errorMessage = String.format("no native library is found for os.name=%s and os.arch=%s", OSInfo.getOSName(), OSInfo.getArchName());
+ throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, errorMessage);
+ }
+
+ // Temporary library folder. Use the value of org.xerial.snappy.tempdir or java.io.tmpdir
+ String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR,
+ System.getProperty("java.io.tmpdir"))).getAbsolutePath();
+
+ // Extract and load a native library inside the jar file
+ return extractLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder);
}
+
+ private static boolean hasResource(String path) {
+ return SnappyLoader.class.getResource(path) != null;
+ }
+
+
+
+
+
/**
* Get the snappy-java version by reading pom.properties embedded in jar.
* This version data is used as a suffix of a dll file extracted from the
diff --git a/src/main/resources/org/xerial/snappy/native/Mac/x86_64/libsnappyjava.dylib b/src/main/resources/org/xerial/snappy/native/Mac/x86_64/libsnappyjava.dylib
deleted file mode 100755
index 6a177ac..0000000
Binary files a/src/main/resources/org/xerial/snappy/native/Mac/x86_64/libsnappyjava.dylib and /dev/null differ