Serializable
, Comparable<SourceVersion>
, Constable
public enum SourceVersion extends Enum<SourceVersion>
Note that additional source version constants will be added to model future releases of the language.
Enum.EnumDesc<E extends Enum<E>>
Enum Constant | Description |
---|---|
RELEASE_0 |
The original version. |
RELEASE_1 |
The version introduced by the Java Platform 1.1. |
RELEASE_10 |
The version introduced by the Java Platform, Standard Edition 10. |
RELEASE_11 |
The version introduced by the Java Platform, Standard Edition 11. |
RELEASE_12 |
The version introduced by the Java Platform, Standard Edition 12. |
RELEASE_13 |
The version introduced by the Java Platform, Standard Edition 13. |
RELEASE_14 |
The version introduced by the Java Platform, Standard Edition 14. |
RELEASE_15 |
The version introduced by the Java Platform, Standard Edition 15. |
RELEASE_16 |
The version introduced by the Java Platform, Standard Edition 16. |
RELEASE_17 |
The version introduced by the Java Platform, Standard Edition 17. |
RELEASE_18 |
The version introduced by the Java Platform, Standard Edition 18. |
RELEASE_19 |
The version introduced by the Java Platform, Standard Edition 19. |
RELEASE_2 |
The version introduced by the Java 2 Platform, Standard Edition, v 1.2. |
RELEASE_20 |
The version introduced by the Java Platform, Standard Edition 20. |
RELEASE_21 |
The version introduced by the Java Platform, Standard Edition 21. |
RELEASE_3 |
The version introduced by the Java 2 Platform, Standard Edition, v 1.3. |
RELEASE_4 |
The version introduced by the Java 2 Platform, Standard Edition, v 1.4. |
RELEASE_5 |
The version introduced by the Java 2 Platform, Standard Edition 5.0. |
RELEASE_6 |
The version introduced by the Java Platform, Standard Edition 6. |
RELEASE_7 |
The version introduced by the Java Platform, Standard Edition 7. |
RELEASE_8 |
The version introduced by the Java Platform, Standard Edition 8. |
RELEASE_9 |
The version introduced by the Java Platform, Standard Edition 9. |
Modifier and Type | Method | Description |
---|---|---|
static boolean |
isIdentifier |
Returns whether or not name is a syntactically valid identifier (simple name) or keyword in the latest source version. |
static boolean |
isKeyword |
Returns whether or not s is a keyword, boolean literal, or null literal in the latest source version. |
static boolean |
isKeyword |
Returns whether or not s is a keyword, boolean literal, or null literal in the given source version. |
static boolean |
isName |
Returns whether or not name is a syntactically valid qualified name in the latest source version. |
static boolean |
isName |
Returns whether or not name is a syntactically valid qualified name in the given source version. |
static SourceVersion |
latest() |
Returns the latest source version that can be modeled. |
static SourceVersion |
latestSupported() |
Returns the latest source version fully supported by the current execution environment. |
Runtime.Version |
runtimeVersion() |
Returns the least runtime version that supports this source version; otherwise null . |
static SourceVersion |
valueOf |
Returns the latest source version that is usable under the runtime version argument. |
static SourceVersion |
valueOf |
Returns the enum constant of this class with the specified name. |
static SourceVersion[] |
values() |
Returns an array containing the constants of this enum class, in the order they are declared. |
public static final SourceVersion RELEASE_0
public static final SourceVersion RELEASE_1
RELEASE_0
augmented with nested classes as described in the 1.1 update to The Java Language Specification, First Edition.public static final SourceVersion RELEASE_2
strictfp
modifier.public static final SourceVersion RELEASE_3
RELEASE_2
.public static final SourceVersion RELEASE_4
public static final SourceVersion RELEASE_5
for
loop, and hexadecimal floating-point literals.public static final SourceVersion RELEASE_6
RELEASE_5
.public static final SourceVersion RELEASE_7
try
-with-resources, strings in switch, binary literals, and multi-catch.public static final SourceVersion RELEASE_8
public static final SourceVersion RELEASE_9
public static final SourceVersion RELEASE_10
var
).public static final SourceVersion RELEASE_11
public static final SourceVersion RELEASE_12
public static final SourceVersion RELEASE_13
public static final SourceVersion RELEASE_14
public static final SourceVersion RELEASE_15
public static final SourceVersion RELEASE_16
instanceof
.public static final SourceVersion RELEASE_17
public static final SourceVersion RELEASE_18
public static final SourceVersion RELEASE_19
public static final SourceVersion RELEASE_20
public static final SourceVersion RELEASE_21
switch
.public static SourceVersion[] values()
public static SourceVersion valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is nullpublic static SourceVersion latest()
public static SourceVersion latestSupported()
RELEASE_9
or later must be returned.latest()
to allow identification of situations where the language model API is running on a platform version different than the latest version modeled by the API. One way that sort of situation can occur is if an IDE or similar tool is using the API to model source version N while running on platform version (N - 1). Running in this configuration is supported by the API. Running an API on platform versions earlier than (N - 1) or later than N may or may not work as an implementation detail. If an annotation processor was generating code to run under the current execution environment, the processor should only use platform features up to the latestSupported
release, which may be earlier than the latest
release.public static boolean isIdentifier(CharSequence name)
name
is a syntactically valid identifier (simple name) or keyword in the latest source version. The method returns true
if the name consists of an initial character for which Character.isJavaIdentifierStart(int)
returns true
, followed only by characters for which Character.isJavaIdentifierPart(int)
returns true
. This pattern matches regular identifiers, keywords, contextual keywords, and the literals "true"
, "false"
, "null"
. The method returns false
for all other strings.name
- the string to checktrue
if this string is a syntactically valid identifier or keyword, false
otherwise.public static boolean isName(CharSequence name)
name
is a syntactically valid qualified name in the latest source version. Syntactically, a qualified name is a sequence of identifiers separated by period characters (".
"). This method splits the input string into period-separated segments and applies checks to each segment in turn. Unlike isIdentifier
, this method returns false
for keywords, boolean literals, and the null literal in any segment. This method returns true
for contextual keywords.name
- the string to checktrue
if this string is a syntactically valid name, false
otherwise.public static boolean isName(CharSequence name, SourceVersion version)
name
is a syntactically valid qualified name in the given source version. Syntactically, a qualified name is a sequence of identifiers separated by period characters (".
"). This method splits the input string into period-separated segments and applies checks to each segment in turn. Unlike isIdentifier
, this method returns false
for keywords, boolean literals, and the null literal in any segment. This method returns true
for contextual keywords.name
- the string to checkversion
- the version to usetrue
if this string is a syntactically valid name, false
otherwise.public static boolean isKeyword(CharSequence s)
s
is a keyword, boolean literal, or null literal in the latest source version. This method returns false
for contextual keywords.s
- the string to checktrue
if s
is a keyword, or boolean literal, or null literal, false
otherwise.public static boolean isKeyword(CharSequence s, SourceVersion version)
s
is a keyword, boolean literal, or null literal in the given source version. This method returns false
for contextual keywords.s
- the string to checkversion
- the version to usetrue
if s
is a keyword, or boolean literal, or null literal, false
otherwise.public static SourceVersion valueOf(Runtime.Version rv)
IllegalArgumentException
is thrown. Because the source versions of the Java programming language have so far followed a linear progression, only the feature component of a runtime version is queried to determine the mapping to a source version. If that linearity changes in the future, other components of the runtime version may influence the result.
"17"
, to the corresponding source version,
RELEASE_17
, is: SourceVersion.valueOf(Runtime.Version.parse("17"))
rv
- runtime version to map to a source versionIllegalArgumentException
- if the feature of version argument is greater than the feature of the platform version.public Runtime.Version runtimeVersion()
null
. The returned runtime version has a feature large enough to support this source version and has no other elements set. Source versions greater than or equal to RELEASE_6
have non-null
results.null
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.compiler/javax/lang/model/SourceVersion.html