Add version check for JDK9 and beyond.

Motivation:

Netty's platform dependent parts should know about JDK9.

Modifications:

JDK9 introduce Runtime$Version Runtime.version() which has an int major()
method that always return the major Java version. I call that method to
get the Java major version.

Result:

Netty will recognize all future JDK versions.
This commit is contained in:
Carsten Varming 2016-06-29 13:04:15 -04:00 committed by Norman Maurer
parent 6af56ffe76
commit 9d933091bf

View File

@ -1030,6 +1030,15 @@ public final class PlatformDependent {
break; break;
} }
try {
Method getVersion = java.lang.Runtime.class.getMethod("version");
Object version = getVersion.invoke(null);
javaVersion = (Integer) version.getClass().getMethod("major").invoke(version);
break;
} catch (Throwable ignored) {
// Ignore
}
try { try {
Class.forName("java.time.Clock", false, getClassLoader(Object.class)); Class.forName("java.time.Clock", false, getClassLoader(Object.class));
javaVersion = 8; javaVersion = 8;