Source versions of the Java™ programming language.
See the appropriate edition of
Note that additional source version constants will be added to
model future releases of the language.
Field Summary |
---|
public SourceVersion | RELEASE_0 | The original version.
The language described in
The Java™ Language Specification, First Edition. |
public SourceVersion | RELEASE_1 | The version recognized by the Java Platform 1.1.
The language is {@code RELEASE_0} augmented with nested classes as described in the 1.1 update to
The Java™ Language Specification, First Edition. |
public 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 the {@code
strictfp} modifier. |
public SourceVersion | RELEASE_3 | The version recognized by the Java 2 Platform, Standard Edition,
v 1.3.
No major changes from {@code RELEASE_2}. |
public SourceVersion | RELEASE_4 | The version recognized by the Java 2 Platform, Standard Edition,
v 1.4.
Added a simple assertion facility. |
public 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, enhanced {@code
for} loop, and hexadecimal floating-point literals. |
public SourceVersion | RELEASE_6 | The version recognized by the Java Platform, Standard Edition
6.
No major changes from {@code RELEASE_5}. |
public SourceVersion | RELEASE_7 | The version recognized by the Java Platform, Standard Edition
7. |
Method from javax.lang.model.SourceVersion Detail: |
public static boolean isIdentifier(CharSequence name) {
String id = name.toString();
if (id.length() == 0) {
return false;
}
int cp = id.codePointAt(0);
if (!Character.isJavaIdentifierStart(cp)) {
return false;
}
for (int i = Character.charCount(cp);
i < id.length();
i += Character.charCount(cp)) {
cp = id.codePointAt(i);
if (!Character.isJavaIdentifierPart(cp)) {
return false;
}
}
return true;
}
Returns whether or not {@code name} is a syntactically valid
identifier (simple name) or keyword in the latest source
version. The method returns {@code true} if the name consists
of an initial character for which Character#isJavaIdentifierStart(int) returns {@code true},
followed only by characters for which Character#isJavaIdentifierPart(int) returns {@code true}.
This pattern matches regular identifiers, keywords, and the
literals {@code "true"}, {@code "false"}, and {@code "null"}.
The method returns {@code false} for all other strings. |
public static boolean isKeyword(CharSequence s) {
String keywordOrLiteral = s.toString();
return keywords.contains(keywordOrLiteral);
}
Returns whether or not {@code s} is a keyword or literal in the
latest source version. |
public static boolean isName(CharSequence name) {
String id = name.toString();
for(String s : id.split("\\.", -1)) {
if (!isIdentifier(s) || isKeyword(s))
return false;
}
return true;
}
Returns whether or not {@code name} is a syntactically valid
qualified name in the latest source version. Unlike isIdentifier , this method returns {@code false}
for keywords and literals. |
public static SourceVersion latest() {
return RELEASE_7;
}
Returns the latest source version that can be modeled. |
public static SourceVersion latestSupported() {
return latestSupported;
}
Returns the latest source version fully supported by the
current execution environment. {@code RELEASE_5} or later must
be returned. |