198 RELEASE_13, 199 200 /** 201 * The version recognized by the Java Platform, Standard Edition 202 * 14. 203 * 204 * Additions in this release include switch expressions. 205 * 206 * @since 14 207 */ 208 RELEASE_14, 209 210 /** 211 * The version recognized by the Java Platform, Standard Edition 212 * 15. 213 * 214 * Additions in this release include text blocks. 215 * 216 * @since 15 217 */ 218 RELEASE_15; 219 220 // Note that when adding constants for newer releases, the 221 // behavior of latest() and latestSupported() must be updated too. 222 223 /** 224 * Returns the latest source version that can be modeled. 225 * 226 * @return the latest source version that can be modeled 227 */ 228 public static SourceVersion latest() { 229 return RELEASE_15; 230 } 231 232 private static final SourceVersion latestSupported = getLatestSupported(); 233 234 /* 235 * The integer version to enum constant mapping implemented by 236 * this method assumes the JEP 322: "Time-Based Release 237 * Versioning" scheme is in effect. This scheme began in JDK 238 * 10. If the JDK versioning scheme is revised, this method may 239 * need to be updated accordingly. 240 */ 241 private static SourceVersion getLatestSupported() { 242 int intVersion = Runtime.version().feature(); 243 return (intVersion >= 11) ? 244 valueOf("RELEASE_" + Math.min(15, intVersion)): 245 RELEASE_10; 246 } 247 248 /** 249 * Returns the latest source version fully supported by the 250 * current execution environment. {@code RELEASE_9} or later must 251 * be returned. 252 * 253 * @apiNote This method is included alongside {@link latest} to 254 * allow identification of situations where the language model API 255 * is running on a platform version different than the latest 256 * version modeled by the API. One way that sort of situation can 257 * occur is if an IDE or similar tool is using the API to model 258 * source version <i>N</i> while running on platform version 259 * (<i>N</i> - 1). Running in this configuration is 260 * supported by the API. Running an API on platform versions 261 * earlier than (<i>N</i> - 1) or later than <i>N</i> 262 * may or may not work as an implementation detail. If an 263 * annotation processor was generating code to run under the 264 * current execution environment, the processor should only use | 198 RELEASE_13, 199 200 /** 201 * The version recognized by the Java Platform, Standard Edition 202 * 14. 203 * 204 * Additions in this release include switch expressions. 205 * 206 * @since 14 207 */ 208 RELEASE_14, 209 210 /** 211 * The version recognized by the Java Platform, Standard Edition 212 * 15. 213 * 214 * Additions in this release include text blocks. 215 * 216 * @since 15 217 */ 218 RELEASE_15, 219 220 /** 221 * The version recognized by the Java Platform, Standard Edition 222 * 16. 223 * 224 * @since 16 225 */ 226 RELEASE_16; 227 228 // Note that when adding constants for newer releases, the 229 // behavior of latest() and latestSupported() must be updated too. 230 231 /** 232 * Returns the latest source version that can be modeled. 233 * 234 * @return the latest source version that can be modeled 235 */ 236 public static SourceVersion latest() { 237 return RELEASE_16; 238 } 239 240 private static final SourceVersion latestSupported = getLatestSupported(); 241 242 /* 243 * The integer version to enum constant mapping implemented by 244 * this method assumes the JEP 322: "Time-Based Release 245 * Versioning" scheme is in effect. This scheme began in JDK 246 * 10. If the JDK versioning scheme is revised, this method may 247 * need to be updated accordingly. 248 */ 249 private static SourceVersion getLatestSupported() { 250 int intVersion = Runtime.version().feature(); 251 return (intVersion >= 11) ? 252 valueOf("RELEASE_" + Math.min(16, intVersion)): 253 RELEASE_10; 254 } 255 256 /** 257 * Returns the latest source version fully supported by the 258 * current execution environment. {@code RELEASE_9} or later must 259 * be returned. 260 * 261 * @apiNote This method is included alongside {@link latest} to 262 * allow identification of situations where the language model API 263 * is running on a platform version different than the latest 264 * version modeled by the API. One way that sort of situation can 265 * occur is if an IDE or similar tool is using the API to model 266 * source version <i>N</i> while running on platform version 267 * (<i>N</i> - 1). Running in this configuration is 268 * supported by the API. Running an API on platform versions 269 * earlier than (<i>N</i> - 1) or later than <i>N</i> 270 * may or may not work as an implementation detail. If an 271 * annotation processor was generating code to run under the 272 * current execution environment, the processor should only use |