56 * 1.7: diamond syntax, try-with-resources, etc. |
56 * 1.7: diamond syntax, try-with-resources, etc. |
57 * 1.8: lambda expressions and default methods |
57 * 1.8: lambda expressions and default methods |
58 * 9: modules, small cleanups to 1.7 and 1.8 changes |
58 * 9: modules, small cleanups to 1.7 and 1.8 changes |
59 * 10: local-variable type inference (var) |
59 * 10: local-variable type inference (var) |
60 * 11: local-variable syntax for lambda parameters |
60 * 11: local-variable syntax for lambda parameters |
61 * 12: no changes (switch expressions in preview) |
61 * 12: no changes (switch expressions were in preview) |
62 * 13: TBD |
62 * 13: no changes (switch expressions and text blocks in preview) |
|
63 * 14: TBD |
63 */ |
64 */ |
64 |
65 |
65 /** |
66 /** |
66 * The original version. |
67 * The original version. |
67 * |
68 * |
190 * The version recognized by the Java Platform, Standard Edition |
191 * The version recognized by the Java Platform, Standard Edition |
191 * 13. |
192 * 13. |
192 * |
193 * |
193 * @since 13 |
194 * @since 13 |
194 */ |
195 */ |
195 RELEASE_13; |
196 RELEASE_13, |
|
197 |
|
198 /** |
|
199 * The version recognized by the Java Platform, Standard Edition |
|
200 * 14. |
|
201 * |
|
202 * @since 14 |
|
203 */ |
|
204 RELEASE_14; |
196 |
205 |
197 // Note that when adding constants for newer releases, the |
206 // Note that when adding constants for newer releases, the |
198 // behavior of latest() and latestSupported() must be updated too. |
207 // behavior of latest() and latestSupported() must be updated too. |
199 |
208 |
200 /** |
209 /** |
201 * Returns the latest source version that can be modeled. |
210 * Returns the latest source version that can be modeled. |
202 * |
211 * |
203 * @return the latest source version that can be modeled |
212 * @return the latest source version that can be modeled |
204 */ |
213 */ |
205 public static SourceVersion latest() { |
214 public static SourceVersion latest() { |
206 return RELEASE_13; |
215 return RELEASE_14; |
207 } |
216 } |
208 |
217 |
209 private static final SourceVersion latestSupported = getLatestSupported(); |
218 private static final SourceVersion latestSupported = getLatestSupported(); |
210 |
219 |
211 /* |
220 /* |
216 * need to be updated accordingly. |
225 * need to be updated accordingly. |
217 */ |
226 */ |
218 private static SourceVersion getLatestSupported() { |
227 private static SourceVersion getLatestSupported() { |
219 int intVersion = Runtime.version().feature(); |
228 int intVersion = Runtime.version().feature(); |
220 return (intVersion >= 11) ? |
229 return (intVersion >= 11) ? |
221 valueOf("RELEASE_" + Math.min(13, intVersion)): |
230 valueOf("RELEASE_" + Math.min(14, intVersion)): |
222 RELEASE_10; |
231 RELEASE_10; |
223 } |
232 } |
224 |
233 |
225 /** |
234 /** |
226 * Returns the latest source version fully supported by the |
235 * Returns the latest source version fully supported by the |
255 * of an initial character for which {@link |
264 * of an initial character for which {@link |
256 * Character#isJavaIdentifierStart(int)} returns {@code true}, |
265 * Character#isJavaIdentifierStart(int)} returns {@code true}, |
257 * followed only by characters for which {@link |
266 * followed only by characters for which {@link |
258 * Character#isJavaIdentifierPart(int)} returns {@code true}. |
267 * Character#isJavaIdentifierPart(int)} returns {@code true}. |
259 * This pattern matches regular identifiers, keywords, restricted |
268 * This pattern matches regular identifiers, keywords, restricted |
260 * keywords, and the literals {@code "true"}, {@code "false"}, |
269 * keywords, restricted identifiers and the literals {@code "true"}, |
261 * {@code "null"}, and {@code "var"}. |
270 * {@code "false"}, {@code "null"}. |
262 * |
271 * |
263 * The method returns {@code false} for all other strings. |
272 * The method returns {@code false} for all other strings. |
264 * |
273 * |
265 * @param name the string to check |
274 * @param name the string to check |
266 * @return {@code true} if this string is a |
275 * @return {@code true} if this string is a |
293 * qualified name in the latest source version. Unlike {@link |
302 * qualified name in the latest source version. Unlike {@link |
294 * #isIdentifier isIdentifier}, this method returns {@code false} |
303 * #isIdentifier isIdentifier}, this method returns {@code false} |
295 * for keywords, boolean literals, and the null literal. |
304 * for keywords, boolean literals, and the null literal. |
296 * |
305 * |
297 * This method returns {@code true} for <i>restricted |
306 * This method returns {@code true} for <i>restricted |
298 * keywords</i> and {@code "var"}. |
307 * keywords</i> and <i>restricted identifiers</i> |
299 * |
308 * |
300 * @param name the string to check |
309 * @param name the string to check |
301 * @return {@code true} if this string is a |
310 * @return {@code true} if this string is a |
302 * syntactically valid name, {@code false} otherwise. |
311 * syntactically valid name, {@code false} otherwise. |
303 * @jls 3.9 Keywords |
312 * @jls 3.9 Keywords |
312 * qualified name in the given source version. Unlike {@link |
321 * qualified name in the given source version. Unlike {@link |
313 * #isIdentifier isIdentifier}, this method returns {@code false} |
322 * #isIdentifier isIdentifier}, this method returns {@code false} |
314 * for keywords, boolean literals, and the null literal. |
323 * for keywords, boolean literals, and the null literal. |
315 * |
324 * |
316 * This method returns {@code true} for <i>restricted |
325 * This method returns {@code true} for <i>restricted |
317 * keywords</i> and {@code "var"}. |
326 * keywords</i> and <i>restricted identifiers</i> |
318 * |
327 * |
319 * @param name the string to check |
328 * @param name the string to check |
320 * @param version the version to use |
329 * @param version the version to use |
321 * @return {@code true} if this string is a |
330 * @return {@code true} if this string is a |
322 * syntactically valid name, {@code false} otherwise. |
331 * syntactically valid name, {@code false} otherwise. |
336 |
345 |
337 /** |
346 /** |
338 * Returns whether or not {@code s} is a keyword, boolean literal, |
347 * Returns whether or not {@code s} is a keyword, boolean literal, |
339 * or null literal in the latest source version. |
348 * or null literal in the latest source version. |
340 * This method returns {@code false} for <i>restricted |
349 * This method returns {@code false} for <i>restricted |
341 * keywords</i> and {@code "var"}. |
350 * keywords</i> and <i>restricted identifiers</i>. |
342 * |
351 * |
343 * @param s the string to check |
352 * @param s the string to check |
344 * @return {@code true} if {@code s} is a keyword, or boolean |
353 * @return {@code true} if {@code s} is a keyword, or boolean |
345 * literal, or null literal, {@code false} otherwise. |
354 * literal, or null literal, {@code false} otherwise. |
346 * @jls 3.9 Keywords |
355 * @jls 3.9 Keywords |
353 |
362 |
354 /** |
363 /** |
355 * Returns whether or not {@code s} is a keyword, boolean literal, |
364 * Returns whether or not {@code s} is a keyword, boolean literal, |
356 * or null literal in the given source version. |
365 * or null literal in the given source version. |
357 * This method returns {@code false} for <i>restricted |
366 * This method returns {@code false} for <i>restricted |
358 * keywords</i> and {@code "var"}. |
367 * keywords</i> and <i>restricted identifiers</i>. |
359 * |
368 * |
360 * @param s the string to check |
369 * @param s the string to check |
361 * @param version the version to use |
370 * @param version the version to use |
362 * @return {@code true} if {@code s} is a keyword, or boolean |
371 * @return {@code true} if {@code s} is a keyword, or boolean |
363 * literal, or null literal, {@code false} otherwise. |
372 * literal, or null literal, {@code false} otherwise. |