< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 151 
 152     // Note that when adding constants for newer releases, the
 153     // behavior of latest() and latestSupported() must be updated too.
 154 
 155     /**
 156      * Returns the latest source version that can be modeled.
 157      *
 158      * @return the latest source version that can be modeled
 159      */
 160     public static SourceVersion latest() {
 161         return RELEASE_9;
 162     }
 163 
 164     private static final SourceVersion latestSupported = getLatestSupported();
 165 
 166     private static SourceVersion getLatestSupported() {
 167         try {
 168             String specVersion = System.getProperty("java.specification.version");
 169 
 170             switch (specVersion) {
 171                 case "1.9":
 172                     return RELEASE_9;
 173                 case "1.8":
 174                     return RELEASE_8;
 175                 case "1.7":
 176                     return RELEASE_7;
 177                 case "1.6":
 178                     return RELEASE_6;
 179             }
 180         } catch (SecurityException se) {}
 181 
 182         return RELEASE_5;
 183     }
 184 
 185     /**
 186      * Returns the latest source version fully supported by the
 187      * current execution environment.  {@code RELEASE_5} or later must
 188      * be returned.
 189      *
 190      * @return the latest source version that is fully supported
 191      */


   1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 151 
 152     // Note that when adding constants for newer releases, the
 153     // behavior of latest() and latestSupported() must be updated too.
 154 
 155     /**
 156      * Returns the latest source version that can be modeled.
 157      *
 158      * @return the latest source version that can be modeled
 159      */
 160     public static SourceVersion latest() {
 161         return RELEASE_9;
 162     }
 163 
 164     private static final SourceVersion latestSupported = getLatestSupported();
 165 
 166     private static SourceVersion getLatestSupported() {
 167         try {
 168             String specVersion = System.getProperty("java.specification.version");
 169 
 170             switch (specVersion) {
 171                 case "9":
 172                     return RELEASE_9;
 173                 case "1.8":
 174                     return RELEASE_8;
 175                 case "1.7":
 176                     return RELEASE_7;
 177                 case "1.6":
 178                     return RELEASE_6;
 179             }
 180         } catch (SecurityException se) {}
 181 
 182         return RELEASE_5;
 183     }
 184 
 185     /**
 186      * Returns the latest source version fully supported by the
 187      * current execution environment.  {@code RELEASE_5} or later must
 188      * be returned.
 189      *
 190      * @return the latest source version that is fully supported
 191      */


< prev index next >