forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 2da3b585b42d058e25909bc303d72277ae2463b5)
to branch 'i2p.i2p.zzz.test' (head 2785f3832a7d1b8adb2f106d049949beb9b88838)
This commit is contained in:
@ -20,6 +20,8 @@ import java.security.DigestException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import net.i2p.util.SystemVersion;
|
||||
|
||||
/**
|
||||
* NOTE: As of 0.8.7, use getInstance() instead of new SHA1(), which will
|
||||
* return the JVM's MessageDigest if it is faster.
|
||||
@ -94,10 +96,8 @@ public final class SHA1 extends MessageDigest implements Cloneable {
|
||||
static {
|
||||
// oddly, Bitzi is faster than Oracle - see test results below
|
||||
boolean useBitzi = true;
|
||||
String vendor = System.getProperty("java.vendor");
|
||||
if (vendor.startsWith("Apache") || // Harmony
|
||||
vendor.startsWith("GNU Classpath") || // JamVM
|
||||
vendor.startsWith("Free Software Foundation")) { // gij
|
||||
if (SystemVersion.isApache() || // Harmony
|
||||
SystemVersion.isGNU()) { // JamVM or gij
|
||||
try {
|
||||
MessageDigest.getInstance("SHA-1");
|
||||
useBitzi = false;
|
||||
|
@ -9,7 +9,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
public class ReusableGZIPInputStream extends ResettableGZIPInputStream {
|
||||
// Apache Harmony 5.0M13 Deflater doesn't work after reset()
|
||||
// Neither does Android
|
||||
private static final boolean ENABLE_CACHING = !(System.getProperty("java.vendor").startsWith("Apache") ||
|
||||
private static final boolean ENABLE_CACHING = !(SystemVersion.isApache() ||
|
||||
SystemVersion.isAndroid());
|
||||
private static final LinkedBlockingQueue<ReusableGZIPInputStream> _available;
|
||||
static {
|
||||
|
@ -20,7 +20,7 @@ import net.i2p.data.DataHelper;
|
||||
public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream {
|
||||
// Apache Harmony 5.0M13 Deflater doesn't work after reset()
|
||||
// Neither does Android
|
||||
private static final boolean ENABLE_CACHING = !(System.getProperty("java.vendor").startsWith("Apache") ||
|
||||
private static final boolean ENABLE_CACHING = !(SystemVersion.isApache() ||
|
||||
SystemVersion.isAndroid());
|
||||
private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available;
|
||||
static {
|
||||
|
@ -15,14 +15,23 @@ public abstract class SystemVersion {
|
||||
|
||||
private static final boolean _isWin = System.getProperty("os.name").startsWith("Win");
|
||||
private static final boolean _isMac = System.getProperty("os.name").startsWith("Mac");
|
||||
private static final boolean _isAndroid = System.getProperty("java.vendor").contains("Android");
|
||||
private static final boolean _isAndroid;
|
||||
private static final boolean _isApache;
|
||||
private static final boolean _isGNU;
|
||||
private static final boolean _is64 = "64".equals(System.getProperty("sun.arch.data.model")) ||
|
||||
System.getProperty("os.arch").contains("64");
|
||||
private static final boolean _hasWrapper = System.getProperty("wrapper.version") != null;
|
||||
|
||||
private static final boolean _oneDotSix;
|
||||
private static final int _androidSDK;
|
||||
|
||||
static {
|
||||
String vendor = System.getProperty("java.vendor");
|
||||
_isAndroid = vendor.contains("Android");
|
||||
_isApache = vendor.startsWith("Apache");
|
||||
_isGNU = vendor.startsWith("GNU Classpath") || // JamVM
|
||||
vendor.startsWith("Free Software Foundation"); // gij
|
||||
|
||||
int sdk = 0;
|
||||
if (_isAndroid) {
|
||||
try {
|
||||
@ -52,6 +61,20 @@ public abstract class SystemVersion {
|
||||
return _isAndroid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apache Harmony JVM, or Android
|
||||
*/
|
||||
public static boolean isApache() {
|
||||
return _isApache || _isAndroid;
|
||||
}
|
||||
|
||||
/**
|
||||
* gij or JamVM with GNU Classpath
|
||||
*/
|
||||
public static boolean isGNU() {
|
||||
return _isGNU;
|
||||
}
|
||||
|
||||
/**
|
||||
* Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0
|
||||
* as it handles Android also, where java.version = "0".
|
||||
@ -90,6 +113,6 @@ public abstract class SystemVersion {
|
||||
* Same as I2PAppContext.hasWrapper()
|
||||
*/
|
||||
public static boolean hasWrapper() {
|
||||
return System.getProperty("wrapper.version") != null;
|
||||
return _hasWrapper;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user