catch UnsatisfiedLinkError
This commit is contained in:
parent
9e95185692
commit
9469afbe38
|
@ -37,7 +37,6 @@ import java.security.DigestInputStream;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -151,12 +150,12 @@ public class SnappyLoader
|
||||||
if (api != null)
|
if (api != null)
|
||||||
return api;
|
return api;
|
||||||
|
|
||||||
final String nativeLoaderClassName = "org.xerial.snappy.SnappyNativeLoader";
|
|
||||||
boolean useNativeCodeInjection = !Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_NATIVE_INJECTION,
|
boolean useNativeCodeInjection = !Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_NATIVE_INJECTION,
|
||||||
"false"));
|
"false"));
|
||||||
|
|
||||||
if (useNativeCodeInjection) {
|
if (useNativeCodeInjection) {
|
||||||
try {
|
try {
|
||||||
|
final String nativeLoaderClassName = "org.xerial.snappy.SnappyNativeLoader";
|
||||||
Class< ? > c = Class.forName(nativeLoaderClassName);
|
Class< ? > c = Class.forName(nativeLoaderClassName);
|
||||||
// If this native loader class is already defined, it means that another class loader already loaded the native library of snappy
|
// If this native loader class is already defined, it means that another class loader already loaded the native library of snappy
|
||||||
api = (SnappyNativeAPI) Class.forName("org.xerial.snappy.SnappyNative").newInstance();
|
api = (SnappyNativeAPI) Class.forName("org.xerial.snappy.SnappyNative").newInstance();
|
||||||
|
@ -179,6 +178,7 @@ public class SnappyLoader
|
||||||
else {
|
else {
|
||||||
if (!isLoaded) {
|
if (!isLoaded) {
|
||||||
// load locally
|
// load locally
|
||||||
|
try {
|
||||||
File nativeLib = findNativeLibrary();
|
File nativeLib = findNativeLibrary();
|
||||||
if (nativeLib != null) {
|
if (nativeLib != null) {
|
||||||
System.load(nativeLib.getAbsolutePath());
|
System.load(nativeLib.getAbsolutePath());
|
||||||
|
@ -188,7 +188,6 @@ public class SnappyLoader
|
||||||
System.loadLibrary("snappyjava");
|
System.loadLibrary("snappyjava");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
api = (SnappyNativeAPI) Class.forName("org.xerial.snappy.SnappyNative").newInstance();
|
api = (SnappyNativeAPI) Class.forName("org.xerial.snappy.SnappyNative").newInstance();
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
}
|
}
|
||||||
|
@ -279,39 +278,6 @@ public class SnappyLoader
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LocalSnappyNativeLoader
|
|
||||||
{
|
|
||||||
// preserved for LocalSnappyNativeLoader
|
|
||||||
private static HashSet<String> loadedLibFiles = new HashSet<String>();
|
|
||||||
private static HashSet<String> loadedLib = new HashSet<String>();
|
|
||||||
|
|
||||||
public static synchronized void load(String lib) {
|
|
||||||
if (loadedLibFiles.contains(lib))
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
System.load(lib);
|
|
||||||
loadedLibFiles.add(lib);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void loadLibrary(String libname) {
|
|
||||||
if (loadedLib.contains(libname))
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
System.loadLibrary(libname);
|
|
||||||
loadedLib.add(libname);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String KEY_SNAPPY_LIB_PATH = "org.xerial.snappy.lib.path";
|
public static final String KEY_SNAPPY_LIB_PATH = "org.xerial.snappy.lib.path";
|
||||||
public static final String KEY_SNAPPY_LIB_NAME = "org.xerial.snappy.lib.name";
|
public static final String KEY_SNAPPY_LIB_NAME = "org.xerial.snappy.lib.name";
|
||||||
public static final String KEY_SNAPPY_TEMPDIR = "org.xerial.snappy.tempdir";
|
public static final String KEY_SNAPPY_TEMPDIR = "org.xerial.snappy.tempdir";
|
||||||
|
|
Loading…
Reference in New Issue