snappy-java: Native library loading fails on openjdk7u4 for mac
What steps will reproduce the problem?
- Install openjdk7u4 preview for mac
- Invoke Snappy#compress
What is the expected output? What do you see instead? I expect Snappy to work. But it fails to find the native library.
What version of the product are you using? On what operating system? Snappy 1.0.4.1, OS X 10.7, OpenJDK7u4
Please provide any additional information below. The openjdk guys have changed System.mapLibraryName to return an extension of "dylib" instead of "jnilib". It looks like this will be the standard for openjdk7 on mac. They have put some backwards compatibility hooks in System.loadLibrary, but this does not help the code in SnappyLoader.
The related code is in SnappyLoader:
// Resolve the library file name with a suffix (e.g., dll, .so, etc.)
if (snappyNativeLibraryName == null)
snappyNativeLibraryName = System.mapLibraryName("snappyjava");
if (snappyNativeLibraryPath != null) {
File nativeLib = new File(snappyNativeLibraryPath, snappyNativeLibraryName);
if (nativeLib.exists())
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) {
On OpenJDK7 on Mac, it attempts to look for libsnappyjava.dylib. In the jar, it is packaged as libsnappyjava.jnilib, so it fails.
It seems the only reasonable fix is to check for both the dylib and jnilib extensions when on a Mac.
Migrated from http://code.google.com/p/snappy-java/issues/detail?id=39
earlier comments
james@tyrrells.com said, at 2012-06-26T04:06:14.000Z:
Duplicating "libsnappyjava.jnilib" with a .dylib extension fixed the issue for me too.
taroleo said, at 2012-06-30T12:04:12.000Z:
Issue 42 has been merged into this issue.
taroleo said, at 2012-06-30T12:04:26.000Z:
Issue 42 has been merged into this issue.
About this issue
- Original URL
- State: closed
- Created 12 years ago
- Comments: 32 (15 by maintainers)
Commits related to this issue
- Fix on issue #6 — committed to xerial/snappy-java by xerial 12 years ago
- Fixes issue #6 — committed to xerial/snappy-java by xerial 12 years ago
- Fixes for issue #6 — committed to xerial/snappy-java by xerial 12 years ago
- Added workaround for Apple's JDK 6 System#mapLibraryName(String). See: https://github.com/mikiobraun/jblas/issues/19 and https://github.com/xerial/snappy-java/issues/6 — committed to virtuoushub/lwjgl3 by deleted user 10 years ago
An easy fix if you want to continue to use 1.4.0.1 on MacOSX with JDK 1.7
unzip snappy-java-1.0.4.1.jar cd org/xerial/snappy/native/Mac/x86_64/ copy libsnappyjava.jnilib libsnappyjava.dylib cd …/…/…/…/…/… cp snappy-java-1.0.4.1.jar snappy-java-1.0.4.1.jar.old jar cf snappy-java-1.0.4.1.jar org