Consolidate Java version checking code, fix bugs

where versions are in different forms
Add warning about Java 7
This commit is contained in:
zzz
2019-05-12 20:20:13 +00:00
parent adb1c6f58e
commit 04a985cd8c
5 changed files with 43 additions and 10 deletions

View File

@ -264,8 +264,8 @@ class NewsFetcher extends UpdateRunner {
}
String minJava = args.get(MIN_JAVA_VERSION_KEY);
if (minJava != null) {
String ourJava = System.getProperty("java.version");
if (VersionComparator.comp(ourJava, minJava) < 0) {
if (!SystemVersion.isJava(minJava)) {
String ourJava = System.getProperty("java.version");
String msg = _mgr._t("Requires Java version {0} but installed Java version is {1}", minJava, ourJava);
_log.logAlways(Log.WARN, "Cannot update to version " + ver + ": " + msg);
_mgr.notifyVersionConstraint(this, _currentURI, ROUTER_SIGNED, "", ver, msg);

View File

@ -409,8 +409,7 @@ class PluginUpdateRunner extends UpdateRunner {
}
minVersion = PluginStarter.stripHTML(props, "min-java-version");
if (minVersion != null &&
VersionComparator.comp(System.getProperty("java.version"), minVersion) < 0) {
if (minVersion != null && !SystemVersion.isJava(minVersion)) {
to.delete();
statusDone("<b>" + _t("This plugin requires Java version {0} or higher", minVersion) + "</b>");
return;

View File

@ -358,8 +358,7 @@ public class PluginStarter implements Runnable {
}
minVersion = stripHTML(props, "min-java-version");
if (minVersion != null &&
VersionComparator.comp(System.getProperty("java.version"), minVersion) < 0) {
if (minVersion != null && !SystemVersion.isJava(minVersion)) {
String foo = "Plugin " + appName + " requires Java version " + minVersion + " or higher";
log.error(foo);
disablePlugin(appName);

View File

@ -340,13 +340,13 @@ public class RouterConsoleRunner implements RouterApp {
/** @since 0.9.17 */
private void checkJavaVersion() {
boolean noJava7 = !SystemVersion.isJava7();
boolean noJava8 = !SystemVersion.isJava8();
boolean noPack200 = (PluginStarter.pluginsEnabled(_context) || !NewsHelper.isUpdateDisabled(_context)) &&
!FileUtil.isPack200Supported();
boolean openARM = SystemVersion.isARM() && SystemVersion.isOpenJDK() && !SystemVersion.isJava9();
boolean isZero = SystemVersion.isZeroVM();
boolean isJava11 = false; // SystemVersion.isJava11();
if (noJava7 || noPack200 || openARM || isZero || isJava11) {
if (noJava8 || noPack200 || openARM || isZero || isJava11) {
String s = "Java version: " + System.getProperty("java.version") +
" OS: " + System.getProperty("os.name") + ' ' +
System.getProperty("os.arch") + ' ' +
@ -354,8 +354,8 @@ public class RouterConsoleRunner implements RouterApp {
net.i2p.util.Log log = _context.logManager().getLog(RouterConsoleRunner.class);
log.logAlways(net.i2p.util.Log.WARN, s);
System.out.println("Warning: " + s);
if (noJava7) {
s = "Java 7 is now required, please upgrade";
if (noJava8) {
s = "Java 8 or higher will be required in a future release, please upgrade Java";
log.logAlways(net.i2p.util.Log.WARN, s);
System.out.println("Warning: " + s);
}