Bug 539570 - Eclipse 2018-09 won't compile Java 11 source; thinks it is
below 1.7

new API - JavaCore.isSupportedJavaVersion()

Change-Id: I4c67993681a6dadc836ed5c8f0c316b6d73cec04
Also-by: Stephan Herrmann <stephan.herrmann@berlin.de>
Signed-off-by: jay <jarthana@in.ibm.com>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index 8b3ef33..0aaaa13 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -826,6 +826,9 @@
 		return 0;
 	}
 	public static long versionToJdkLevel(String versionID) {
+		return versionToJdkLevel(versionID, true);
+	}
+	public static long versionToJdkLevel(String versionID, boolean supportUnreleased) {
 		String version = versionID;
 		// verification is optimized for all versions with same length and same "1." prefix
 		if (version != null && version.length() > 0) {
@@ -860,7 +863,13 @@
 						if (index != -1)
 							version = version.substring(0, index);
 					}
-					int major = Math.min(Integer.parseInt(version) + ClassFileConstants.MAJOR_VERSION_0, ClassFileConstants.MAJOR_LATEST_VERSION);
+					int major = Integer.parseInt(version) + ClassFileConstants.MAJOR_VERSION_0;
+					if (major > ClassFileConstants.MAJOR_LATEST_VERSION) {
+						if (supportUnreleased)
+							major = ClassFileConstants.MAJOR_LATEST_VERSION;
+						else
+							return 0; // unknown
+					}
 					return ((long) major << 16) + ClassFileConstants.MINOR_VERSION_0;
 				} catch (NumberFormatException e) {
 					// do nothing and return 0 at the end
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
index 37f5bd0..f5e15bd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
@@ -3048,6 +3048,21 @@
 	}
 
 	/**
+	 * Returns whether the given version of Java or Java Runtime is supported 
+	 * by the Java Development Toolkit.
+	 * 
+	 * A true indicates that the given version is supported. For e.g., if the argument
+	 * is <code>11.0.1</code> and {@link #getAllVersions()} contains <code>11</code>, 
+	 * the method returns <code>true</code>.
+	 * 
+	 * @return a boolean indicating support for the given version of Java or Java Runtime.
+	 * @since 3.16
+	 */
+	public static boolean isSupportedJavaVersion(String version) {
+		return CompilerOptions.versionToJdkLevel(version, false) > 0;
+	}
+
+	/**
 	 * Configurable option value: {@value}.
 	 * @since 2.0
 	 * @category OptionValue