Fix DependencyChecks failing in Java 9+ environments
@@ -17,10 +17,13 @@ public class DependencyChecks {
public static boolean check() {
double version = getVersion();
if (version == 1.8) {
+ // Java 8
return checkJFX();
} else if (version > 1.8) {
+ // Java 9+
return true;
} else {
+ // Java 7-
err("Outdated Java", "Please update java to the latest of Java 8 before using Recaf.");
return false;
}
@@ -28,6 +31,8 @@ public class DependencyChecks {
private static boolean checkJFX() {
String extra = "";
+ // Checking these classes because JavaFX used to be linked to the actual Java release.
+ // Some early versions of 1.8 are 'missing' these classes. So verify we have them.
if (!exists("javafx.application.Application$Parameters") || !exists("javafx.scene.control.MenuBar") || !exists(
"javafx.scene.control.Menu")) {
err("Mising JavaFX classes", "Could not load required JavaFX classes.\n" + extra);
@@ -52,6 +57,8 @@ public class DependencyChecks {
public static double getVersion() {
String version = System.getProperty("java.version");
int pos = version.indexOf('.');
+ if (pos == -1)
+ return Double.parseDouble(version);
pos = version.indexOf('.', pos + 1);
return Double.parseDouble(version.substring(0, pos));
}
