-
CSR
-
Resolution: Approved
-
P4
-
minimal
-
Java API
-
SE
Summary
Add version-sensitive isName
and isKeyword
methods to SourceVersion
.
Problem
The javax.lang.model.SourceVersion enum doesn't expose much information that varies by release, such as the set of keywords.
Solution
Add new methods for isName and isKeyword which are version-aware.
Specification
+ /**
+ * Returns whether or not {@code name} is a syntactically valid
+ * qualified name in the given source version. Unlike {@link
+ * #isIdentifier isIdentifier}, this method returns {@code false}
+ * for keywords and literals.
+ *
+ * @param name the string to check
+ * @param version the version to use
+ * @return {@code true} if this string is a
+ * syntactically valid name, {@code false} otherwise.
+ * @jls 6.2 Names and Identifiers
+ * @since 9
+ */
+ public static boolean isName(CharSequence name, SourceVersion version)
+
+ /**
+ * Returns whether or not {@code s} is a keyword or literal in the
+ * given source version.
+ *
+ * @param s the string to check
+ * @param version the version to use
+ * @return {@code true} if {@code s} is a keyword or literal, {@code false} otherwise.
+ * @since 9
+ */
+ public static boolean isKeyword(CharSequence s, SourceVersion version
- csr for
-
JDK-6415644 Make javax.lang.model.SourceVersion more informative
-
- Closed
-