#1191: Do not start on pre-release Java 17

Pre-release versions of Java may miss standard API that is introduced later during development of the same release. Unfortunately some server hosts knowingly (!) run these versions in production, even years after the general availability of that java release. Therefore, we need to manually enforce that the server only runs on fully standardized versions to ensure compatibility of plugin and server code with the runtime.

To cause less problems when developers test their software with newer Java, this rule is only enforced on the oldest Java release the server can run with. This is the Java version all plugins will normally compile to, so it's feature set must always be available during runtime.

By: saltyaimbotter <saltyaimbotter@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2023-06-03 11:39:00 +10:00
parent ce8a5d4953
commit e894c4d08c

View file

@ -169,6 +169,13 @@ public class Main {
System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 20 is supported.");
return;
}
String javaVersionName = System.getProperty("java.version");
// J2SE SDK/JRE Version String Naming Convention
boolean isPreRelease = javaVersionName.contains("-");
if (isPreRelease && javaVersion == 61.0) {
System.err.println("Unsupported Java detected (" + javaVersionName + "). You are running an outdated, pre-release version. Only general availability versions of Java are supported. Please update your Java version.");
return;
}
try {
// This trick bypasses Maven Shade's clever rewriting of our getProperty call when using String literals