getAllVersions() {
return allVersions;
}
+ /**
+ * Returns all Java source versions fully supported by Eclipse compiler in the order of their introduction. For
+ * example, {@link JavaCore#VERSION_1_8} appears before {@link JavaCore#VERSION_10}.
+ *
+ * Note, some not included older or newer Java versions might be known by Eclipse compiler internally but not
+ * exposed via this API because compiler does not support these anymore (or yet).
+ *
+ * @return all Java source versions fully supported by Eclipse compiler
+ * @see #isJavaSourceVersionSupportedByCompiler(String)
+ * @see #getFirstJavaSourceVersionSupportedByCompiler()
+ * @since 3.39
+ */
+ public static List getAllJavaSourceVersionsSupportedByCompiler() {
+ return SUPPORTED_VERSIONS;
+ }
+
/**
* Returns whether the given version of Java or Java Runtime is supported
* by the Java Development Toolkit.
@@ -3352,6 +3386,22 @@ public static boolean isSupportedJavaVersion(String version) {
return CompilerOptions.versionToJdkLevel(version, false) > 0;
}
+ /**
+ * Not all known Java versions are supported by Eclipse compiler. This method answers if the given Java source
+ * version is fully supported.
+ *
+ * @return {@code true} if the given string represents Java language version is fully supported by Eclipse compiler
+ * @see #getAllJavaSourceVersionsSupportedByCompiler()
+ * @see #getFirstJavaSourceVersionSupportedByCompiler()
+ * @since 3.39
+ */
+ public static boolean isJavaSourceVersionSupportedByCompiler(String version) {
+ if(version == null || version.isBlank()) {
+ return false;
+ }
+ return SUPPORTED_VERSIONS.contains(version);
+ }
+
/**
* Configurable option value: {@value}.
* @since 2.0
@@ -6453,6 +6503,20 @@ public static void setOptions(Hashtable newOptions) {
public static String latestSupportedJavaVersion() {
return allVersions.get(allVersions.size() - 1);
}
+
+ /**
+ * First (oldest) Java source version supported by the Eclipse compiler.
+ * This is the first entry from {@link JavaCore#getAllJavaSourceVersionsSupportedByCompiler()}.
+ *
+ * @return first (oldest) Java source version supported by the Eclipse compiler
+ * @see #getAllJavaSourceVersionsSupportedByCompiler()
+ * @see #isJavaSourceVersionSupportedByCompiler(String)
+ * @since 3.39
+ */
+ public static String getFirstJavaSourceVersionSupportedByCompiler() {
+ return SUPPORTED_VERSIONS.get(0);
+ }
+
/**
* Compares two given versions of the Java platform. The versions being compared must both be
* one of the supported values mentioned in