< prev index next >

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

Print this page




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


 143     RELEASE_8,
 144 
 145     /**
 146      * The version recognized by the Java Platform, Standard Edition
 147      * 9.
 148      *
 149      * Additions in this release include modules and removal of a
 150      * single underscore from the set of legal identifier names.
 151      *
 152      * @since 9
 153      */
 154      RELEASE_9,
 155 
 156     /**
 157      * The version recognized by the Java Platform, Standard Edition
 158      * 10.
 159      *
 160      * Additions in this release include local-variable type inference
 161      * ({@code var}).
 162      *



 163      * @since 10
 164      */
 165      RELEASE_10;








 166 
 167     // Note that when adding constants for newer releases, the
 168     // behavior of latest() and latestSupported() must be updated too.
 169 
 170     /**
 171      * Returns the latest source version that can be modeled.
 172      *
 173      * @return the latest source version that can be modeled
 174      */
 175     public static SourceVersion latest() {
 176         return RELEASE_10;
 177     }
 178 
 179     private static final SourceVersion latestSupported = getLatestSupported();
 180 
 181     private static SourceVersion getLatestSupported() {
 182         try {
 183             String specVersion = System.getProperty("java.specification.version");
 184 
 185             switch (specVersion) {


 186                 case "10":
 187                     return RELEASE_10;
 188                 case "9":
 189                     return RELEASE_9;
 190                 case "1.8":
 191                     return RELEASE_8;
 192                 case "1.7":
 193                     return RELEASE_7;
 194                 case "1.6":
 195                     return RELEASE_6;
 196             }
 197         } catch (SecurityException se) {}
 198 
 199         return RELEASE_5;
 200     }
 201 
 202     /**
 203      * Returns the latest source version fully supported by the
 204      * current execution environment.  {@code RELEASE_5} or later must
 205      * be returned.




  40  * model future releases of the language.
  41  *
  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: to be determined changes
  61      */
  62 
  63     /**
  64      * The original version.
  65      *
  66      * The language described in
  67      * <cite>The Java&trade; Language Specification, First Edition</cite>.
  68      */
  69     RELEASE_0,
  70 
  71     /**
  72      * The version recognized by the Java Platform 1.1.
  73      *
  74      * The language is {@code RELEASE_0} augmented with nested classes as described in the 1.1 update to
  75      * <cite>The Java&trade; Language Specification, First Edition</cite>.
  76      */
  77     RELEASE_1,
  78 
  79     /**
  80      * The version recognized by the Java 2 Platform, Standard Edition,


 144     RELEASE_8,
 145 
 146     /**
 147      * The version recognized by the Java Platform, Standard Edition
 148      * 9.
 149      *
 150      * Additions in this release include modules and removal of a
 151      * single underscore from the set of legal identifier names.
 152      *
 153      * @since 9
 154      */
 155      RELEASE_9,
 156 
 157     /**
 158      * The version recognized by the Java Platform, Standard Edition
 159      * 10.
 160      *
 161      * Additions in this release include local-variable type inference
 162      * ({@code var}).
 163      *
 164      * Additions in this release include local variable type inference
 165      * ({@code var}). 
 166      *
 167      * @since 10
 168      */
 169      RELEASE_10,
 170 
 171     /**
 172      * The version recognized by the Java Platform, Standard Edition
 173      * 11.
 174      *
 175      * @since 11
 176      */
 177      RELEASE_11;
 178 
 179     // Note that when adding constants for newer releases, the
 180     // behavior of latest() and latestSupported() must be updated too.
 181 
 182     /**
 183      * Returns the latest source version that can be modeled.
 184      *
 185      * @return the latest source version that can be modeled
 186      */
 187     public static SourceVersion latest() {
 188         return RELEASE_11;
 189     }
 190 
 191     private static final SourceVersion latestSupported = getLatestSupported();
 192 
 193     private static SourceVersion getLatestSupported() {
 194         try {
 195             String specVersion = System.getProperty("java.specification.version");
 196 
 197             switch (specVersion) {
 198                 case "11":
 199                     return RELEASE_11;
 200                 case "10":
 201                     return RELEASE_10;
 202                 case "9":
 203                     return RELEASE_9;
 204                 case "1.8":
 205                     return RELEASE_8;
 206                 case "1.7":
 207                     return RELEASE_7;
 208                 case "1.6":
 209                     return RELEASE_6;
 210             }
 211         } catch (SecurityException se) {}
 212 
 213         return RELEASE_5;
 214     }
 215 
 216     /**
 217      * Returns the latest source version fully supported by the
 218      * current execution environment.  {@code RELEASE_5} or later must
 219      * be returned.


< prev index next >