Move "isSlow" detection to SystemVersion

This commit is contained in:
zzz
2017-03-18 14:38:59 +00:00
parent fda673038f
commit 05aef9bd59
5 changed files with 25 additions and 10 deletions

View File

@ -116,11 +116,7 @@ public final class KeyGenerator {
/** @since 0.9.8 */ /** @since 0.9.8 */
private static final boolean DEFAULT_USE_LONG_EXPONENT = private static final boolean DEFAULT_USE_LONG_EXPONENT =
NativeBigInteger.isNative() && !SystemVersion.isSlow();
SystemVersion.is64Bit() &&
!SystemVersion.isGNU() &&
!SystemVersion.isApache() &&
!SystemVersion.isARM();
/** /**
* @deprecated use getElGamalExponentSize() which allows override in the properties * @deprecated use getElGamalExponentSize() which allows override in the properties

View File

@ -39,6 +39,7 @@ public abstract class SystemVersion {
private static final boolean _is64; private static final boolean _is64;
private static final boolean _hasWrapper = System.getProperty("wrapper.version") != null; private static final boolean _hasWrapper = System.getProperty("wrapper.version") != null;
private static final boolean _isLinuxService; private static final boolean _isLinuxService;
private static final boolean _isSlow;
private static final boolean _oneDotSix; private static final boolean _oneDotSix;
private static final boolean _oneDotSeven; private static final boolean _oneDotSeven;
@ -69,6 +70,7 @@ public abstract class SystemVersion {
_isLinuxService = !_isWin && !_isMac && !_isAndroid && _isLinuxService = !_isWin && !_isMac && !_isAndroid &&
(DAEMON_USER.equals(System.getProperty("user.name")) || (DAEMON_USER.equals(System.getProperty("user.name")) ||
(_isGentoo && GENTOO_USER.equals(System.getProperty("user.name")))); (_isGentoo && GENTOO_USER.equals(System.getProperty("user.name"))));
_isSlow = _isAndroid || _isApache || _isArm || _isGNU || getMaxMemory() < 48*1024*1024L;
int sdk = 0; int sdk = 0;
if (_isAndroid) { if (_isAndroid) {
@ -153,6 +155,18 @@ public abstract class SystemVersion {
return _isX86; return _isX86;
} }
/**
* Our best guess on whether this is a slow architecture / OS / JVM,
* using some simple heuristics.
*
* @since 0.9.30
*/
public static boolean isSlow() {
// we don't put the NBI call in the static field,
// to prevent a circular initialization with NBI.
return _isSlow || !NativeBigInteger.isNative();
}
/** /**
* Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") &gt;= 0 * Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") &gt;= 0
* as it handles Android also, where java.version = "0". * as it handles Android also, where java.version = "0".
@ -290,6 +304,7 @@ public abstract class SystemVersion {
System.out.println("Linux Svc: " + isLinuxService()); System.out.println("Linux Svc: " + isLinuxService());
System.out.println("Mac : " + isMac()); System.out.println("Mac : " + isMac());
System.out.println("OpenJDK : " + isOpenJDK()); System.out.println("OpenJDK : " + isOpenJDK());
System.out.println("Slow : " + isSlow());
System.out.println("Windows : " + isWindows()); System.out.println("Windows : " + isWindows());
System.out.println("Wrapper : " + hasWrapper()); System.out.println("Wrapper : " + hasWrapper());
System.out.println("x86 : " + isX86()); System.out.println("x86 : " + isX86());

View File

@ -1,3 +1,10 @@
2017-03-18 zzz
* Addressbook (ticket #1966):
- Build as jar, not war
- Put empty war in updater
- Move Servlet starter to SusiDNS
- Skip war in RouterConsoleRunner
2017-03-14 zzz 2017-03-14 zzz
* Blockfile: Fix specified-destination deletion from the correct book * Blockfile: Fix specified-destination deletion from the correct book
* i2ptunnel: * i2ptunnel:

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 6; public final static long BUILD = 7;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";

View File

@ -65,10 +65,7 @@ public class TunnelPoolSettings {
public static final int DEFAULT_DURATION = 10*60*1000; public static final int DEFAULT_DURATION = 10*60*1000;
//public static final int DEFAULT_LENGTH = SystemVersion.isAndroid() ? 2 : 3; //public static final int DEFAULT_LENGTH = SystemVersion.isAndroid() ? 2 : 3;
private static final boolean isSlow = SystemVersion.isGNU() || private static final boolean isSlow = SystemVersion.isSlow();
SystemVersion.isARM() ||
SystemVersion.isApache() ||
!NativeBigInteger.isNative();
/** client only */ /** client only */
private static final int DEFAULT_IB_LENGTH = 3; private static final int DEFAULT_IB_LENGTH = 3;