From d6aa1ad509670b22702cf75500c5f66dc4cea2cd Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 16 Aug 2017 16:39:37 -0700 Subject: [PATCH] Make Java 8 detection work on Java 9 Closes #393. --- .../worldedit/bukkit/WorldEditPlugin.java | 4 ++-- ...{Java8Detector.java => Java7Detector.java} | 22 +++++++++---------- .../sk89q/worldedit/forge/ForgeWorldEdit.java | 1 - 3 files changed, 13 insertions(+), 14 deletions(-) rename worldedit-core/src/main/java/com/sk89q/worldedit/util/{Java8Detector.java => Java7Detector.java} (73%) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 4ffde3d85..a432bcc4c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -48,7 +48,7 @@ import com.sk89q.worldedit.regions.CylinderRegion; import com.sk89q.worldedit.regions.Polygonal2DRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; -import com.sk89q.worldedit.util.Java8Detector; +import com.sk89q.worldedit.util.Java7Detector; import org.bukkit.World; import org.bukkit.command.Command; @@ -121,7 +121,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { loadAdapter(); // Need an adapter to work with special blocks with NBT data // Check Java version - Java8Detector.notifyIfNot8(); + Java7Detector.notifyIfNot8(); } private void loadConfig() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Java8Detector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Java7Detector.java similarity index 73% rename from worldedit-core/src/main/java/com/sk89q/worldedit/util/Java8Detector.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/util/Java7Detector.java index 71a05d667..d825073a2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Java8Detector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Java7Detector.java @@ -18,21 +18,21 @@ */ package com.sk89q.worldedit.util; -import com.google.common.base.Joiner; import com.sk89q.worldedit.WorldEdit; -public final class Java8Detector { +public final class Java7Detector { public static void notifyIfNot8() { - String[] ver = System.getProperty("java.version").split("\\."); - int major = Integer.parseInt(ver[1]); - if (major <= 7) { - // Implicitly java 7 because we compile against 7, so this won't - // even launch on 6. + int major = -1; + try { + String[] ver = System.getProperty("java.version").split("\\."); + major = Integer.parseInt(ver[1]); + } catch (Exception ignored) { + } + + if (major == 7) { WorldEdit.logger.warning( - "WorldEdit has detected you are using Java 7" - + " (based on detected version " - + Joiner.on('.').join(ver) + ")."); + "WorldEdit has detected you are using Java 7."); WorldEdit.logger.warning( "WorldEdit will stop supporting Java less than version 8 in the future," + " due to Java 7 being EOL since April 2015." @@ -40,7 +40,7 @@ public final class Java8Detector { } } - private Java8Detector() { + private Java7Detector() { } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java index 3f4efbb14..11d20c2f4 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java @@ -30,7 +30,6 @@ import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage; import com.sk89q.worldedit.internal.LocalWorldAdapter; -import com.sk89q.worldedit.util.Java8Detector; import java.io.File; import java.util.Map;