- java.lang.Object
- 
- java.lang.Enum<SourceVersion>
- 
- javax.lang.model.SourceVersion
 
 
- 
- All Implemented Interfaces:
- Serializable,- Comparable<SourceVersion>
 
 public enum SourceVersion extends Enum<SourceVersion> Source versions of the Java™ programming language. See the appropriate edition of The Java™ Language Specification for information about a particular source version.Note that additional source version constants will be added to model future releases of the language. - Since:
- 1.6
 
- 
- 
Enum Constant SummaryEnum Constants Enum Constant Description RELEASE_0The original version.RELEASE_1The version recognized by the Java Platform 1.1.RELEASE_10The version recognized by the Java Platform, Standard Edition 10.RELEASE_11The version recognized by the Java Platform, Standard Edition 11.RELEASE_2The version recognized by the Java 2 Platform, Standard Edition, v 1.2.RELEASE_3The version recognized by the Java 2 Platform, Standard Edition, v 1.3.RELEASE_4The version recognized by the Java 2 Platform, Standard Edition, v 1.4.RELEASE_5The version recognized by the Java 2 Platform, Standard Edition 5.0.RELEASE_6The version recognized by the Java Platform, Standard Edition 6.RELEASE_7The version recognized by the Java Platform, Standard Edition 7.RELEASE_8The version recognized by the Java Platform, Standard Edition 8.RELEASE_9The version recognized by the Java Platform, Standard Edition 9.
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisIdentifier(CharSequence name)Returns whether or notnameis a syntactically valid identifier (simple name) or keyword in the latest source version.static booleanisKeyword(CharSequence s)Returns whether or notsis a keyword, boolean literal, or null literal in the latest source version.static booleanisKeyword(CharSequence s, SourceVersion version)Returns whether or notsis a keyword, boolean literal, or null literal in the given source version.static booleanisName(CharSequence name)Returns whether or notnameis a syntactically valid qualified name in the latest source version.static booleanisName(CharSequence name, SourceVersion version)Returns whether or notnameis a syntactically valid qualified name in the given source version.static SourceVersionlatest()Returns the latest source version that can be modeled.static SourceVersionlatestSupported()Returns the latest source version fully supported by the current execution environment.static SourceVersionvalueOf(String name)Returns the enum constant of this type with the specified name.static SourceVersion[]values()Returns an array containing the constants of this enum type, in the order they are declared.
 
- 
- 
- 
Enum Constant Detail- 
RELEASE_0public static final SourceVersion RELEASE_0 The original version. The language described in The Java™ Language Specification, First Edition.
 - 
RELEASE_1public static final SourceVersion RELEASE_1 The version recognized by the Java Platform 1.1. The language isRELEASE_0augmented with nested classes as described in the 1.1 update to The Java™ Language Specification, First Edition.
 - 
RELEASE_2public static final SourceVersion RELEASE_2 The version recognized by the Java 2 Platform, Standard Edition, v 1.2. The language described in The Java™ Language Specification, Second Edition, which includes thestrictfpmodifier.
 - 
RELEASE_3public static final SourceVersion RELEASE_3 The version recognized by the Java 2 Platform, Standard Edition, v 1.3. No major changes fromRELEASE_2.
 - 
RELEASE_4public static final SourceVersion RELEASE_4 The version recognized by the Java 2 Platform, Standard Edition, v 1.4. Added a simple assertion facility.
 - 
RELEASE_5public static final SourceVersion RELEASE_5 The version recognized by the Java 2 Platform, Standard Edition 5.0. The language described in The Java™ Language Specification, Third Edition. First release to support generics, annotations, autoboxing, var-args, enhancedforloop, and hexadecimal floating-point literals.
 - 
RELEASE_6public static final SourceVersion RELEASE_6 The version recognized by the Java Platform, Standard Edition 6. No major changes fromRELEASE_5.
 - 
RELEASE_7public static final SourceVersion RELEASE_7 The version recognized by the Java Platform, Standard Edition 7. Additions in this release include, diamond syntax for constructors,try-with-resources, strings in switch, binary literals, and multi-catch.- Since:
- 1.7
 
 - 
RELEASE_8public static final SourceVersion RELEASE_8 The version recognized by the Java Platform, Standard Edition 8. Additions in this release include lambda expressions and default methods.- Since:
- 1.8
 
 - 
RELEASE_9public static final SourceVersion RELEASE_9 The version recognized by the Java Platform, Standard Edition 9. Additions in this release include modules and removal of a single underscore from the set of legal identifier names.- Since:
- 9
 
 - 
RELEASE_10public static final SourceVersion RELEASE_10 The version recognized by the Java Platform, Standard Edition 10. Additions in this release include local-variable type inference (var).- Since:
- 10
 
 - 
RELEASE_11public static final SourceVersion RELEASE_11 The version recognized by the Java Platform, Standard Edition 11.- Since:
- 11
 
 
- 
 - 
Method Detail- 
valuespublic static SourceVersion[] values() Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SourceVersion c : SourceVersion.values()) System.out.println(c); - Returns:
- an array containing the constants of this enum type, in the order they are declared
 
 - 
valueOfpublic static SourceVersion valueOf(String name) Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
- name- the name of the enum constant to be returned.
- Returns:
- the enum constant with the specified name
- Throws:
- IllegalArgumentException- if this enum type has no constant with the specified name
- NullPointerException- if the argument is null
 
 - 
latestpublic static SourceVersion latest() Returns the latest source version that can be modeled.- Returns:
- the latest source version that can be modeled
 
 - 
latestSupportedpublic static SourceVersion latestSupported() Returns the latest source version fully supported by the current execution environment.RELEASE_5or later must be returned.- Returns:
- the latest source version that is fully supported
 
 - 
isIdentifierpublic static boolean isIdentifier(CharSequence name) Returns whether or notnameis a syntactically valid identifier (simple name) or keyword in the latest source version. The method returnstrueif the name consists of an initial character for whichCharacter.isJavaIdentifierStart(int)returnstrue, followed only by characters for whichCharacter.isJavaIdentifierPart(int)returnstrue. This pattern matches regular identifiers, keywords, restricted keywords, and the literals"true","false","null", and"var". The method returnsfalsefor all other strings.- Parameters:
- name- the string to check
- Returns:
- trueif this string is a syntactically valid identifier or keyword,- falseotherwise.
 
 - 
isNamepublic static boolean isName(CharSequence name) Returns whether or notnameis a syntactically valid qualified name in the latest source version. UnlikeisIdentifier, this method returnsfalsefor keywords, boolean literals, and the null literal. This method returnstruefor restricted keywords and"var".- Parameters:
- name- the string to check
- Returns:
- trueif this string is a syntactically valid name,- falseotherwise.
- See The Java™ Language Specification:
- 3.9 Keywords, 6.2 Names and Identifiers
 
 - 
isNamepublic static boolean isName(CharSequence name, SourceVersion version) Returns whether or notnameis a syntactically valid qualified name in the given source version. UnlikeisIdentifier, this method returnsfalsefor keywords, boolean literals, and the null literal. This method returnstruefor restricted keywords and"var".- Parameters:
- name- the string to check
- version- the version to use
- Returns:
- trueif this string is a syntactically valid name,- falseotherwise.
- Since:
- 9
- See The Java™ Language Specification:
- 3.9 Keywords, 6.2 Names and Identifiers
 
 - 
isKeywordpublic static boolean isKeyword(CharSequence s) Returns whether or notsis a keyword, boolean literal, or null literal in the latest source version. This method returnsfalsefor restricted keywords and"var".- Parameters:
- s- the string to check
- Returns:
- trueif- sis a keyword, or boolean literal, or null literal,- falseotherwise.
- See The Java™ Language Specification:
- 3.9 Keywords, 3.10.3 Boolean Literals, 3.10.7 The Null Literal
 
 - 
isKeywordpublic static boolean isKeyword(CharSequence s, SourceVersion version) Returns whether or notsis a keyword, boolean literal, or null literal in the given source version. This method returnsfalsefor restricted keywords and"var".- Parameters:
- s- the string to check
- version- the version to use
- Returns:
- trueif- sis a keyword, or boolean literal, or null literal,- falseotherwise.
- Since:
- 9
- See The Java™ Language Specification:
- 3.9 Keywords, 3.10.3 Boolean Literals, 3.10.7 The Null Literal
 
 
- 
 
-