diff --git a/CHANGELOG.md b/CHANGELOG.md index dc3ede2..819b1c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +**1.0.3** +* Improve Java Binary Testing + **1.0.2** * Fix 32-Bit OpenJDk Installation diff --git a/gradle.properties b/gradle.properties index 4dc1512..9240878 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G fabric_loader_version = 0.9.0+build.204 # Mod Properties - mod_version = 1.0.2 + mod_version = 1.0.3 maven_group = com.thebrokenrail # Dependencies diff --git a/src/main/java/com/thebrokenrail/freshcoffee/FreshCoffee.java b/src/main/java/com/thebrokenrail/freshcoffee/FreshCoffee.java index 6e62051..c87188e 100644 --- a/src/main/java/com/thebrokenrail/freshcoffee/FreshCoffee.java +++ b/src/main/java/com/thebrokenrail/freshcoffee/FreshCoffee.java @@ -23,7 +23,7 @@ public class FreshCoffee implements PreLaunchEntrypoint { System.exit(1); } - ReLaunchUtil.reLaunch(); + ReLaunchUtil.reLaunch(true); // Download Available JDKs AdoptOpenJDK.JDK jdk = AdoptOpenJDK.get().get(PlatformUtil.getPlatform()); @@ -49,7 +49,7 @@ public class FreshCoffee implements PreLaunchEntrypoint { ExtractUtil.extract(url, dir); - ReLaunchUtil.reLaunch(); + ReLaunchUtil.reLaunch(false); } System.exit(1); diff --git a/src/main/java/com/thebrokenrail/freshcoffee/util/ReLaunchUtil.java b/src/main/java/com/thebrokenrail/freshcoffee/util/ReLaunchUtil.java index 1943e56..e20b4f5 100644 --- a/src/main/java/com/thebrokenrail/freshcoffee/util/ReLaunchUtil.java +++ b/src/main/java/com/thebrokenrail/freshcoffee/util/ReLaunchUtil.java @@ -110,24 +110,33 @@ public final class ReLaunchUtil { } } + private static void javaBinaryTestFailed(String reason) { + Util.getLogger().debug("Java Binary Test Failed: " + reason); + } + private static boolean testJavaBinary(String javaBinary) { + Util.getLogger().debug("Testing Java Binary: " + javaBinary); + Process process; try { process = new ProcessBuilder(javaBinary, "-version").start(); } catch (IOException e) { + javaBinaryTestFailed(e.toString()); return false; } try { int status = process.waitFor(); + javaBinaryTestFailed("Exit Code: " + status); return status == 0; } catch (InterruptedException e) { + javaBinaryTestFailed(e.toString()); process.destroy(); return false; } } - public static void reLaunch() { + public static void reLaunch(boolean testJavaBinary) { File[] files = HardcodedConfig.INSTALL_DIR.listFiles(); if (files != null) { List list = new ArrayList<>(); @@ -142,7 +151,7 @@ public final class ReLaunchUtil { if (newestVersion != null) { File javaDir = Util.getJavaDir(newestVersion); File javaBinary = new File(new File(javaDir, "bin"), "java" + PlatformUtil.getExecutableExtension()); - if (javaBinary.exists() && javaBinary.canExecute() && testJavaBinary(javaBinary.getAbsolutePath())) { + if (!testJavaBinary || testJavaBinary(javaBinary.getAbsolutePath())) { Util.getLogger().info("Using Java Executable: " + javaBinary.getAbsolutePath()); reLaunch(javaBinary.getAbsolutePath()); } else {