backwards compatibility - first check for jbigi.dll / libjbigi.so, then do the new stuff ("jbigi" in a jar, followed by "net/i2p/util/libjbigi-linux-pentium4.so", etc)

This commit is contained in:
jrandom
2004-08-21 09:29:18 +00:00
committed by zzz
parent bee9c7ee17
commit 3c772f1974

View File

@ -374,7 +374,13 @@ public class NativeBigInteger extends BigInteger {
String wantedProp = System.getProperty("jbigi.enable", "true"); String wantedProp = System.getProperty("jbigi.enable", "true");
boolean wantNative = "true".equalsIgnoreCase(wantedProp); boolean wantNative = "true".equalsIgnoreCase(wantedProp);
if (wantNative) { if (wantNative) {
boolean loaded = loadFromResource("jbigi"); boolean loaded = loadGeneric("jbigi");
if (loaded) {
_nativeOk = true;
if (_doLog)
System.err.println("INFO: Locally optimized native BigInteger loaded from the library path");
} else {
loaded = loadFromResource("jbigi");
if (loaded) { if (loaded) {
_nativeOk = true; _nativeOk = true;
if (_doLog) if (_doLog)
@ -411,6 +417,7 @@ public class NativeBigInteger extends BigInteger {
} }
} }
} }
}
if (_doLog && !_nativeOk) if (_doLog && !_nativeOk)
System.err.println("INFO: Native BigInteger library jbigi not loaded - using pure java"); System.err.println("INFO: Native BigInteger library jbigi not loaded - using pure java");
}catch(Exception e){ }catch(Exception e){
@ -427,8 +434,10 @@ public class NativeBigInteger extends BigInteger {
* *
*/ */
private static final boolean loadGeneric(boolean optimized) { private static final boolean loadGeneric(boolean optimized) {
return loadGeneric(getMiddleName(optimized));
}
private static final boolean loadGeneric(String name) {
try { try {
String name = getMiddleName(optimized);
if(name == null) if(name == null)
return false; return false;
System.loadLibrary(name); System.loadLibrary(name);