< prev index next >

src/java.compiler/share/classes/javax/lang/model/SourceVersion.java

Print this page




  42  * @author Joseph D. Darcy
  43  * @author Scott Seligman
  44  * @author Peter von der Ah&eacute;
  45  * @since 1.6
  46  */
  47 public enum SourceVersion {
  48     /*
  49      * Summary of language evolution
  50      * 1.1: nested classes
  51      * 1.2: strictfp
  52      * 1.3: no changes
  53      * 1.4: assert
  54      * 1.5: annotations, generics, autoboxing, var-args...
  55      * 1.6: no changes
  56      * 1.7: diamond syntax, try-with-resources, etc.
  57      * 1.8: lambda expressions and default methods
  58      *   9: modules, small cleanups to 1.7 and 1.8 changes
  59      *  10: local-variable type inference (var)
  60      *  11: local-variable syntax for lambda parameters
  61      *  12: TBD

  62      */
  63 
  64     /**
  65      * The original version.
  66      *
  67      * The language described in
  68      * <cite>The Java&trade; Language Specification, First Edition</cite>.
  69      */
  70     RELEASE_0,
  71 
  72     /**
  73      * The version recognized by the Java Platform 1.1.
  74      *
  75      * The language is {@code RELEASE_0} augmented with nested classes as described in the 1.1 update to
  76      * <cite>The Java&trade; Language Specification, First Edition</cite>.
  77      */
  78     RELEASE_1,
  79 
  80     /**
  81      * The version recognized by the Java 2 Platform, Standard Edition,


 166      */
 167      RELEASE_10,
 168 
 169     /**
 170      * The version recognized by the Java Platform, Standard Edition
 171      * 11.
 172      *
 173      * Additions in this release include local-variable syntax for
 174      * lambda parameters.
 175      *
 176      * @since 11
 177      */
 178      RELEASE_11,
 179 
 180     /**
 181      * The version recognized by the Java Platform, Standard Edition
 182      * 12.
 183      *
 184      * @since 12
 185      */
 186      RELEASE_12;








 187 
 188     // Note that when adding constants for newer releases, the
 189     // behavior of latest() and latestSupported() must be updated too.
 190 
 191     /**
 192      * Returns the latest source version that can be modeled.
 193      *
 194      * @return the latest source version that can be modeled
 195      */
 196     public static SourceVersion latest() {
 197         return RELEASE_12;
 198     }
 199 
 200     private static final SourceVersion latestSupported = getLatestSupported();
 201 
 202     private static SourceVersion getLatestSupported() {
 203         try {
 204             String specVersion = System.getProperty("java.specification.version");
 205 
 206             switch (specVersion) {


 207                 case "12":
 208                     return RELEASE_12;
 209                 case "11":
 210                     return RELEASE_11;
 211                 case "10":
 212                     return RELEASE_10;
 213                 case "9":
 214                     return RELEASE_9;
 215                 case "1.8":
 216                     return RELEASE_8;
 217                 case "1.7":
 218                     return RELEASE_7;
 219                 case "1.6":
 220                     return RELEASE_6;
 221             }
 222         } catch (SecurityException se) {}
 223 
 224         return RELEASE_5;
 225     }
 226 




  42  * @author Joseph D. Darcy
  43  * @author Scott Seligman
  44  * @author Peter von der Ah&eacute;
  45  * @since 1.6
  46  */
  47 public enum SourceVersion {
  48     /*
  49      * Summary of language evolution
  50      * 1.1: nested classes
  51      * 1.2: strictfp
  52      * 1.3: no changes
  53      * 1.4: assert
  54      * 1.5: annotations, generics, autoboxing, var-args...
  55      * 1.6: no changes
  56      * 1.7: diamond syntax, try-with-resources, etc.
  57      * 1.8: lambda expressions and default methods
  58      *   9: modules, small cleanups to 1.7 and 1.8 changes
  59      *  10: local-variable type inference (var)
  60      *  11: local-variable syntax for lambda parameters
  61      *  12: TBD
  62      *  13: TBD
  63      */
  64 
  65     /**
  66      * The original version.
  67      *
  68      * The language described in
  69      * <cite>The Java&trade; Language Specification, First Edition</cite>.
  70      */
  71     RELEASE_0,
  72 
  73     /**
  74      * The version recognized by the Java Platform 1.1.
  75      *
  76      * The language is {@code RELEASE_0} augmented with nested classes as described in the 1.1 update to
  77      * <cite>The Java&trade; Language Specification, First Edition</cite>.
  78      */
  79     RELEASE_1,
  80 
  81     /**
  82      * The version recognized by the Java 2 Platform, Standard Edition,


 167      */
 168      RELEASE_10,
 169 
 170     /**
 171      * The version recognized by the Java Platform, Standard Edition
 172      * 11.
 173      *
 174      * Additions in this release include local-variable syntax for
 175      * lambda parameters.
 176      *
 177      * @since 11
 178      */
 179      RELEASE_11,
 180 
 181     /**
 182      * The version recognized by the Java Platform, Standard Edition
 183      * 12.
 184      *
 185      * @since 12
 186      */
 187      RELEASE_12,
 188 
 189     /**
 190      * The version recognized by the Java Platform, Standard Edition
 191      * 13.
 192      *
 193      * @since 13
 194      */
 195      RELEASE_13;
 196 
 197     // Note that when adding constants for newer releases, the
 198     // behavior of latest() and latestSupported() must be updated too.
 199 
 200     /**
 201      * Returns the latest source version that can be modeled.
 202      *
 203      * @return the latest source version that can be modeled
 204      */
 205     public static SourceVersion latest() {
 206         return RELEASE_13;
 207     }
 208 
 209     private static final SourceVersion latestSupported = getLatestSupported();
 210 
 211     private static SourceVersion getLatestSupported() {
 212         try {
 213             String specVersion = System.getProperty("java.specification.version");
 214 
 215             switch (specVersion) {
 216                 case "13":
 217                     return RELEASE_13;
 218                 case "12":
 219                     return RELEASE_12;
 220                 case "11":
 221                     return RELEASE_11;
 222                 case "10":
 223                     return RELEASE_10;
 224                 case "9":
 225                     return RELEASE_9;
 226                 case "1.8":
 227                     return RELEASE_8;
 228                 case "1.7":
 229                     return RELEASE_7;
 230                 case "1.6":
 231                     return RELEASE_6;
 232             }
 233         } catch (SecurityException se) {}
 234 
 235         return RELEASE_5;
 236     }
 237 


< prev index next >