mirror of
https://github.com/xerial/snappy-java.git
synced 2025-04-08 19:35:08 +02:00
initialize local snappy loader
This commit is contained in:
parent
94d5356ba9
commit
9c86835cc3
@ -190,13 +190,14 @@ public class SnappyLoader
|
|||||||
boolean useNativeCodeInjection = !Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_NATIVE_INJECTION,
|
boolean useNativeCodeInjection = !Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_NATIVE_INJECTION,
|
||||||
"false"));
|
"false"));
|
||||||
|
|
||||||
|
try {
|
||||||
if (!useNativeCodeInjection) {
|
if (!useNativeCodeInjection) {
|
||||||
// Use the local loader
|
// Use the local loader
|
||||||
return LocalSnappyNativeLoader.class;
|
return SnappyLoader.class.getClassLoader().loadClass(LocalSnappyNativeLoader.class.getName());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Use parent class loader to load SnappyNative, since Tomcat, which uses different class loaders for each webapps, cannot load JNI interface twice
|
// Use parent class loader to load SnappyNative, since Tomcat, which uses different class loaders for each webapps, cannot load JNI interface twice
|
||||||
try {
|
|
||||||
final String nativeLoaderClassName = "org.xerial.snappy.SnappyNativeLoader";
|
final String nativeLoaderClassName = "org.xerial.snappy.SnappyNativeLoader";
|
||||||
ClassLoader rootClassLoader = getRootClassLoader();
|
ClassLoader rootClassLoader = getRootClassLoader();
|
||||||
// Load a byte code
|
// Load a byte code
|
||||||
@ -235,11 +236,11 @@ public class SnappyLoader
|
|||||||
// Load the SnappyNativeLoader class
|
// Load the SnappyNativeLoader class
|
||||||
return rootClassLoader.loadClass(nativeLoaderClassName);
|
return rootClassLoader.loadClass(nativeLoaderClassName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage());
|
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user