Skip to content

Commit

Permalink
Make Java 8 detection work on Java 9
Browse files Browse the repository at this point in the history
Closes #393.
  • Loading branch information
octylFractal committed Aug 16, 2017
1 parent 6c6e1b4 commit d6aa1ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Expand Up @@ -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() {
}

}
Expand Up @@ -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;
Expand Down

2 comments on commit d6aa1ad

@mibby
Copy link

@mibby mibby commented on d6aa1ad Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@14mRh4X0r
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.