Utils: Java 9 yakkety workarounds

This commit is contained in:
zzz
2017-01-17 14:08:47 +00:00
parent 7cae467b59
commit a36083ab18
3 changed files with 56 additions and 4 deletions

View File

@ -330,15 +330,34 @@ public class DeallocationHelper {
// drops the "-internal" suffix from the major version number for // drops the "-internal" suffix from the major version number for
// an early access build (Ubuntu) // an early access build (Ubuntu)
javaVersionElements[0] = javaVersionElements[0].substring(0, indexOfEarlyAccessSuffix); javaVersionElements[0] = javaVersionElements[0].substring(0, indexOfEarlyAccessSuffix);
} else {
indexOfEarlyAccessSuffix = javaVersionElements[0].lastIndexOf("-Ubuntu");
if (indexOfEarlyAccessSuffix != -1) {
// drops the "-Ubuntu suffix from the major version number for
// an early access build (Ubuntu)
javaVersionElements[0] = javaVersionElements[0].substring(0, indexOfEarlyAccessSuffix);
}
} }
} }
final int major, minor; final int major, minor;
if (javaVersionElements.length >= 2) { if (javaVersionElements.length >= 2) {
major = Integer.parseInt(javaVersionElements[0]); major = Integer.parseInt(javaVersionElements[0]);
minor = Integer.parseInt(javaVersionElements[1]); int min;
try {
min = Integer.parseInt(javaVersionElements[1]);
} catch (NumberFormatException nfe) {
min = 7;
}
minor = min;
} else { } else {
major = 1; major = 1;
minor = Integer.parseInt(javaVersionElements[0]); int min;
try {
min = Integer.parseInt(javaVersionElements[0]);
} catch (NumberFormatException nfe) {
min = 7;
}
minor = min;
} }
final String directBufferAttachmentFieldName; final String directBufferAttachmentFieldName;
if (minor == 1 && major <= 6) if (minor == 1 && major <= 6)

View File

@ -5,7 +5,8 @@ import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
/** /**
* Moved from CryptixAESEngine and net.i2p.router.tasks.CryptoChecker * Moved from CryptixAESEngine and net.i2p.router.tasks.CryptoChecker.
* This class does not do any logging. See CryptoChecker for the logging.
* *
* @since 0.9.23 * @since 0.9.23
*/ */
@ -28,6 +29,33 @@ public class CryptoCheck {
unlimited = true; unlimited = true;
} catch (GeneralSecurityException gse) { } catch (GeneralSecurityException gse) {
} }
} catch (ExceptionInInitializerError eiie) {
// Java 9 b134 bug
// > java -jar build/i2p.jar cryptocheck
// Exception in thread "main" java.lang.ExceptionInInitializerError
// at javax.crypto.JceSecurityManager.<clinit>(java.base@9-Ubuntu/JceSecurityManager.java:65)
// at javax.crypto.Cipher.getConfiguredPermission(java.base@9-Ubuntu/Cipher.java:2595)
// at javax.crypto.Cipher.getMaxAllowedKeyLength(java.base@9-Ubuntu/Cipher.java:2619)
// at net.i2p.crypto.CryptoCheck.<clinit>(CryptoCheck.java:19)
// at java.lang.Class.forName0(java.base@9-Ubuntu/Native Method)
// at java.lang.Class.forName(java.base@9-Ubuntu/Class.java:374)
// at net.i2p.util.CommandLine.exec(CommandLine.java:66)
// at net.i2p.util.CommandLine.main(CommandLine.java:51)
// Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
// at javax.crypto.JceSecurity.<clinit>(java.base@9-Ubuntu/JceSecurity.java:91)
// ... 8 more
// Caused by: java.lang.NullPointerException
// at sun.nio.fs.UnixPath.normalizeAndCheck(java.base@9-Ubuntu/UnixPath.java:75)
// at sun.nio.fs.UnixPath.<init>(java.base@9-Ubuntu/UnixPath.java:69)
// at sun.nio.fs.UnixFileSystem.getPath(java.base@9-Ubuntu/UnixFileSystem.java:280)
// at java.nio.file.Paths.get(java.base@9-Ubuntu/Paths.java:84)
// at javax.crypto.JceSecurity.setupJurisdictionPolicies(java.base@9-Ubuntu/JceSecurity.java:254)
// at javax.crypto.JceSecurity.access$000(java.base@9-Ubuntu/JceSecurity.java:49)
// at javax.crypto.JceSecurity$1.run(java.base@9-Ubuntu/JceSecurity.java:82)
// at javax.crypto.JceSecurity$1.run(java.base@9-Ubuntu/JceSecurity.java:79)
// at java.security.AccessController.doPrivileged(java.base@9-Ubuntu/Native Method)
// at javax.crypto.JceSecurity.<clinit>(java.base@9-Ubuntu/JceSecurity.java:78)
// ... 8 more
} }
_isUnlimited = unlimited; _isUnlimited = unlimited;
} }

View File

@ -57,8 +57,13 @@ public class CryptoChecker {
if (log != null) if (log != null)
log.logAlways(Log.WARN, s); log.logAlways(Log.WARN, s);
System.out.println(s); System.out.println(s);
} else if (SystemVersion.isJava9()) {
s = "Java 9 support is beta, check for Java updates";
if (log != null)
log.logAlways(Log.WARN, s);
System.out.println("Warning: " + s);
} }
if (!CryptoCheck.isUnlimited()) { if (!CryptoCheck.isUnlimited() && !SystemVersion.isJava9()) {
s = "Please consider installing the Java Cryptography Unlimited Strength Jurisdiction Policy Files from "; s = "Please consider installing the Java Cryptography Unlimited Strength Jurisdiction Policy Files from ";
//if (SystemVersion.isJava8()) //if (SystemVersion.isJava8())
// s += JRE8; // s += JRE8;