mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-12 16:44:28 +02:00
Fixes issue 20
Applied a patch from tucu to disable the default behaviour with a JVM option org.xerial.snappy.disable.bundled.libs.
This commit is contained in:
parent
ba8a761010
commit
1607113e36
@ -89,6 +89,7 @@ public class SnappyLoader
|
|||||||
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";
|
||||||
|
public static final String KEY_SNAPPY_DISABLE_BUNDLED_LIBS = "org.xerial.snappy.disable.bundled.libs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the MD5 value of the input stream
|
* Computes the MD5 value of the input stream
|
||||||
@ -204,7 +205,8 @@ public class SnappyLoader
|
|||||||
if (isLoaded)
|
if (isLoaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Try loading the library from org.xerial.snappy.lib.path library path */
|
if (System.getProperty(KEY_SNAPPY_DISABLE_BUNDLED_LIBS, "false").equals("false")) {
|
||||||
|
// Try to load the library from org.xerial.snappy.lib.path library path */
|
||||||
String snappyNativeLibraryPath = System.getProperty(KEY_SNAPPY_LIB_PATH);
|
String snappyNativeLibraryPath = System.getProperty(KEY_SNAPPY_LIB_PATH);
|
||||||
String snappyNativeLibraryName = System.getProperty(KEY_SNAPPY_LIB_NAME);
|
String snappyNativeLibraryName = System.getProperty(KEY_SNAPPY_LIB_NAME);
|
||||||
|
|
||||||
@ -219,21 +221,23 @@ public class SnappyLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load an os-dependent native library inside a jar file
|
// Load an OS-dependent native library inside a jar file
|
||||||
snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
|
snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
|
||||||
|
|
||||||
if (SnappyLoader.class.getResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName) != null) {
|
if (SnappyLoader.class.getResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName) != null) {
|
||||||
// Temporary library folder. Use the value of java.io.tmpdir
|
// 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")))
|
String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR,
|
||||||
.getAbsolutePath();
|
System.getProperty("java.io.tmpdir"))).getAbsolutePath();
|
||||||
|
|
||||||
// Try extracting the library from jar
|
// Extract and load a native library inside the jar file
|
||||||
if (extractAndLoadLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder)) {
|
if (extractAndLoadLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder)) {
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Try to load snappyjava DLL in LD_PATH
|
}
|
||||||
|
|
||||||
|
// Try to load snappyjava DLL in LD_LIBRARY_PATH
|
||||||
try {
|
try {
|
||||||
System.loadLibrary("snappyjava");
|
System.loadLibrary("snappyjava");
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
|
@ -41,8 +41,8 @@ public class SnappyLoaderTest
|
|||||||
ClassRealm L1 = cw.newRealm("l1", parent);
|
ClassRealm L1 = cw.newRealm("l1", parent);
|
||||||
ClassRealm L2 = cw.newRealm("l2", parent);
|
ClassRealm L2 = cw.newRealm("l2", parent);
|
||||||
|
|
||||||
Class< ? > snappyClass = L1.loadClass("org.xerial.snappy.Snappy");
|
//Class< ? > snappyClass = L1.loadClass("org.xerial.snappy.Snappy"); // not found
|
||||||
_logger.info(snappyClass.getName());
|
//_logger.info(snappyClass.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user