langtools/src/share/classes/javax/lang/model/SourceVersion.java
changeset 22169 4be6dc44489b
parent 22163 3651128c74eb
equal deleted inserted replaced
22168:a48fe7ec473d 22169:4be6dc44489b
    53      * 1.4: assert
    53      * 1.4: assert
    54      * 1.5: annotations, generics, autoboxing, var-args...
    54      * 1.5: annotations, generics, autoboxing, var-args...
    55      * 1.6: no changes
    55      * 1.6: no changes
    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      * 1.9: To be determined
    58      */
    59      */
    59 
    60 
    60     /**
    61     /**
    61      * The original version.
    62      * The original version.
    62      *
    63      *
   136      * 8.
   137      * 8.
   137      *
   138      *
   138      * Additions in this release include lambda expressions and default methods.
   139      * Additions in this release include lambda expressions and default methods.
   139      * @since 1.8
   140      * @since 1.8
   140      */
   141      */
   141     RELEASE_8;
   142     RELEASE_8,
       
   143 
       
   144     /**
       
   145      * The version recognized by the Java Platform, Standard Edition
       
   146      * 9.
       
   147      *
       
   148      * @since 1.9
       
   149      */
       
   150      RELEASE_9;
   142 
   151 
   143     // Note that when adding constants for newer releases, the
   152     // Note that when adding constants for newer releases, the
   144     // behavior of latest() and latestSupported() must be updated too.
   153     // behavior of latest() and latestSupported() must be updated too.
   145 
   154 
   146     /**
   155     /**
   147      * Returns the latest source version that can be modeled.
   156      * Returns the latest source version that can be modeled.
   148      *
   157      *
   149      * @return the latest source version that can be modeled
   158      * @return the latest source version that can be modeled
   150      */
   159      */
   151     public static SourceVersion latest() {
   160     public static SourceVersion latest() {
   152         return RELEASE_8;
   161         return RELEASE_9;
   153     }
   162     }
   154 
   163 
   155     private static final SourceVersion latestSupported = getLatestSupported();
   164     private static final SourceVersion latestSupported = getLatestSupported();
   156 
   165 
   157     private static SourceVersion getLatestSupported() {
   166     private static SourceVersion getLatestSupported() {
   158         try {
   167         try {
   159             String specVersion = System.getProperty("java.specification.version");
   168             String specVersion = System.getProperty("java.specification.version");
   160 
   169 
   161             switch (specVersion) {
   170             switch (specVersion) {
       
   171                 case "1.9":
       
   172                     return RELEASE_9;
   162                 case "1.8":
   173                 case "1.8":
   163                     return RELEASE_8;
   174                     return RELEASE_8;
   164                 case "1.7":
   175                 case "1.7":
   165                     return RELEASE_7;
   176                     return RELEASE_7;
   166                 case "1.6":
   177                 case "1.6":
   269      *
   280      *
   270      * @param s the string to check
   281      * @param s the string to check
   271      * @return {@code true} if {@code s} is a keyword or literal, {@code false} otherwise.
   282      * @return {@code true} if {@code s} is a keyword or literal, {@code false} otherwise.
   272      */
   283      */
   273     public static boolean isKeyword(CharSequence s) {
   284     public static boolean isKeyword(CharSequence s) {
   274         String keywordOrLiteral = s.toString();
   285         return keywords.contains(s.toString());
   275         return keywords.contains(keywordOrLiteral);
       
   276     }
   286     }
   277 }
   287 }