Permalink
Browse files

Make Java 8 detection work on Java 9

Closes #393.
  • Loading branch information...
kenzierocks committed Aug 16, 2017
1 parent 6c6e1b4 commit d6aa1ad509670b22702cf75500c5f66dc4cea2cd
@@ -48,7 +48,7 @@
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 void onEnable() {
loadAdapter(); // Need an adapter to work with special blocks with NBT data
// Check Java version
Java8Detector.notifyIfNot8();
Java7Detector.notifyIfNot8();
}
private void loadConfig() {
@@ -18,29 +18,29 @@
*/
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."
+ " Please update your server to Java 8.");
}
}
private Java8Detector() {
private Java7Detector() {
}
}
@@ -30,7 +30,6 @@
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;

2 comments on commit d6aa1ad

@mibby

This comment has been minimized.

Show comment
Hide comment
@mibby

mibby Aug 18, 2017

@wizjany Builds are failing to compile on the build server.

mibby replied Aug 18, 2017

@wizjany Builds are failing to compile on the build server.

@14mRh4X0r

This comment has been minimized.

Show comment
Hide comment
@14mRh4X0r

14mRh4X0r Aug 19, 2017

This will tell the user to upgrade to Java 8 at the 7th minor release of Java 9; java.version will then be 9.7.0.

14mRh4X0r replied Aug 19, 2017

This will tell the user to upgrade to Java 8 at the 7th minor release of Java 9; java.version will then be 9.7.0.

Please sign in to comment.