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 */
private static final boolean DEFAULT_USE_LONG_EXPONENT =
NativeBigInteger.isNative() &&
SystemVersion.is64Bit() &&
!SystemVersion.isGNU() &&
!SystemVersion.isApache() &&
!SystemVersion.isARM();
!SystemVersion.isSlow();
/**
* @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 _hasWrapper = System.getProperty("wrapper.version") != null;
private static final boolean _isLinuxService;
private static final boolean _isSlow;
private static final boolean _oneDotSix;
private static final boolean _oneDotSeven;
@ -69,6 +70,7 @@ public abstract class SystemVersion {
_isLinuxService = !_isWin && !_isMac && !_isAndroid &&
(DAEMON_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;
if (_isAndroid) {
@ -153,6 +155,18 @@ public abstract class SystemVersion {
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
* 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("Mac : " + isMac());
System.out.println("OpenJDK : " + isOpenJDK());
System.out.println("Slow : " + isSlow());
System.out.println("Windows : " + isWindows());
System.out.println("Wrapper : " + hasWrapper());
System.out.println("x86 : " + isX86());