1 /*
2 * Copyright (c) 2005, 2006, 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
107 * Third Edition</cite>. First release to support
108 * generics, annotations, autoboxing, var-args, enhanced {@code
109 * for} loop, and hexadecimal floating-point literals.
110 */
111 RELEASE_5,
112
113 /**
114 * The version recognized by the Java Platform, Standard Edition
115 * 6.
116 *
117 * No major changes from {@code RELEASE_5}.
118 */
119 RELEASE_6,
120
121 /**
122 * The version recognized by the Java Platform, Standard Edition
123 * 7.
124 *
125 * @since 1.7
126 */
127 RELEASE_7;
128
129 // Note that when adding constants for newer releases, the
130 // behavior of latest() and latestSupported() must be updated too.
131
132 /**
133 * Returns the latest source version that can be modeled.
134 *
135 * @return the latest source version that can be modeled
136 */
137 public static SourceVersion latest() {
138 return RELEASE_7;
139 }
140
141 private static final SourceVersion latestSupported = getLatestSupported();
142
143 private static SourceVersion getLatestSupported() {
144 try {
145 String specVersion = System.getProperty("java.specification.version");
146 if ("1.7".equals(specVersion))
147 return RELEASE_7;
148 else if ("1.6".equals(specVersion))
149 return RELEASE_6;
150 } catch (SecurityException se) {}
151
152 return RELEASE_5;
153 }
154
155 /**
156 * Returns the latest source version fully supported by the
157 * current execution environment. {@code RELEASE_5} or later must
158 * be returned.
159 *
160 * @return the latest source version that is fully supported
161 */
162 public static SourceVersion latestSupported() {
163 return latestSupported;
164 }
165
166 /**
167 * Returns whether or not {@code name} is a syntactically valid
168 * identifier (simple name) or keyword in the latest source
|
1 /*
2 * Copyright (c) 2005, 2011, 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
107 * Third Edition</cite>. First release to support
108 * generics, annotations, autoboxing, var-args, enhanced {@code
109 * for} loop, and hexadecimal floating-point literals.
110 */
111 RELEASE_5,
112
113 /**
114 * The version recognized by the Java Platform, Standard Edition
115 * 6.
116 *
117 * No major changes from {@code RELEASE_5}.
118 */
119 RELEASE_6,
120
121 /**
122 * The version recognized by the Java Platform, Standard Edition
123 * 7.
124 *
125 * @since 1.7
126 */
127 RELEASE_7,
128
129 /**
130 * The version recognized by the Java Platform, Standard Edition
131 * 8.
132 *
133 * @since 1.8
134 */
135 RELEASE_8;
136
137 // Note that when adding constants for newer releases, the
138 // behavior of latest() and latestSupported() must be updated too.
139
140 /**
141 * Returns the latest source version that can be modeled.
142 *
143 * @return the latest source version that can be modeled
144 */
145 public static SourceVersion latest() {
146 return RELEASE_8;
147 }
148
149 private static final SourceVersion latestSupported = getLatestSupported();
150
151 private static SourceVersion getLatestSupported() {
152 try {
153 String specVersion = System.getProperty("java.specification.version");
154
155 if ("1.8".equals(specVersion))
156 return RELEASE_8;
157 else if("1.7".equals(specVersion))
158 return RELEASE_7;
159 else if("1.6".equals(specVersion))
160 return RELEASE_6;
161 } catch (SecurityException se) {}
162
163 return RELEASE_5;
164 }
165
166 /**
167 * Returns the latest source version fully supported by the
168 * current execution environment. {@code RELEASE_5} or later must
169 * be returned.
170 *
171 * @return the latest source version that is fully supported
172 */
173 public static SourceVersion latestSupported() {
174 return latestSupported;
175 }
176
177 /**
178 * Returns whether or not {@code name} is a syntactically valid
179 * identifier (simple name) or keyword in the latest source
|