< prev index next >
src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
Print this page
*** 56,66 ****
* 1.7: diamond syntax, try-with-resources, etc.
* 1.8: lambda expressions and default methods
* 9: modules, small cleanups to 1.7 and 1.8 changes
* 10: local-variable type inference (var)
* 11: local-variable syntax for lambda parameters
! * 12: TBD
* 13: TBD
*/
/**
* The original version.
--- 56,66 ----
* 1.7: diamond syntax, try-with-resources, etc.
* 1.8: lambda expressions and default methods
* 9: modules, small cleanups to 1.7 and 1.8 changes
* 10: local-variable type inference (var)
* 11: local-variable syntax for lambda parameters
! * 12: no changes (switch expressions in preview)
* 13: TBD
*/
/**
* The original version.
*** 206,247 ****
return RELEASE_13;
}
private static final SourceVersion latestSupported = getLatestSupported();
private static SourceVersion getLatestSupported() {
! try {
! String specVersion = System.getProperty("java.specification.version");
!
! switch (specVersion) {
! case "13":
! return RELEASE_13;
! case "12":
! return RELEASE_12;
! case "11":
! return RELEASE_11;
! case "10":
! return RELEASE_10;
! case "9":
! return RELEASE_9;
! case "1.8":
! return RELEASE_8;
! case "1.7":
! return RELEASE_7;
! case "1.6":
! return RELEASE_6;
! }
! } catch (SecurityException se) {}
!
! return RELEASE_5;
}
/**
* Returns the latest source version fully supported by the
! * current execution environment. {@code RELEASE_5} or later must
* be returned.
*
* @return the latest source version that is fully supported
*/
public static SourceVersion latestSupported() {
return latestSupported;
}
--- 206,245 ----
return RELEASE_13;
}
private static final SourceVersion latestSupported = getLatestSupported();
+ /*
+ * The integer to release enum constant implemented by this method
+ * assumes the JEP 322: "Time-Based Release Versioning" scheme is
+ * in effect. This scheme began in JDK 10. If the JDK versioning
+ * scheme is revised, this method may need to be updated
+ * accordingly.
+ */
private static SourceVersion getLatestSupported() {
! int intVersion = Runtime.version().feature();
! return (intVersion >= 11) ?
! valueOf("RELEASE_" + Math.min(13, intVersion)):
! RELEASE_10;
}
/**
* Returns the latest source version fully supported by the
! * current execution environment. {@code RELEASE_9} or later must
* be returned.
*
+ * @apiNote This method is included alongside {@link latest} to
+ * allow situations where the language model API is running on a
+ * platform version different than the latest version modeled by
+ * the API to be identified. One way that sort of situation can
+ * occur is if a IDE or similar tool is using the API to model
+ * source version <i>N</i> while running on platform version
+ * (<i>N</i> - 1). Running in this configuration is
+ * supported by the API. Running an API on platform versions
+ * earlier than (<i>N</i> - 1) or later than <i>N</i>
+ * may or may not work as an implementation detail.
+ *
* @return the latest source version that is fully supported
*/
public static SourceVersion latestSupported() {
return latestSupported;
}
< prev index next >