142 */ 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 * @since 10 161 */ 162 RELEASE_10; 163 164 // Note that when adding constants for newer releases, the 165 // behavior of latest() and latestSupported() must be updated too. 166 167 /** 168 * Returns the latest source version that can be modeled. 169 * 170 * @return the latest source version that can be modeled 171 */ 172 public static SourceVersion latest() { 173 return RELEASE_10; 174 } 175 176 private static final SourceVersion latestSupported = getLatestSupported(); 177 178 private static SourceVersion getLatestSupported() { 179 try { 180 String specVersion = System.getProperty("java.specification.version"); 181 182 switch (specVersion) { 183 case "10": 184 return RELEASE_10; 185 case "9": 186 return RELEASE_9; 187 case "1.8": 188 return RELEASE_8; 189 case "1.7": 190 return RELEASE_7; 191 case "1.6": 192 return RELEASE_6; 193 } 194 } catch (SecurityException se) {} 195 196 return RELEASE_5; 197 } 198 199 /** 200 * Returns the latest source version fully supported by the 201 * current execution environment. {@code RELEASE_5} or later must 202 * be returned. | 142 */ 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 * @since 10 161 */ 162 RELEASE_10, 163 164 /** 165 * The version recognized by the Java Platform, Standard Edition 166 * 11. 167 * 168 * @since 11 169 */ 170 RELEASE_11; 171 172 // Note that when adding constants for newer releases, the 173 // behavior of latest() and latestSupported() must be updated too. 174 175 /** 176 * Returns the latest source version that can be modeled. 177 * 178 * @return the latest source version that can be modeled 179 */ 180 public static SourceVersion latest() { 181 return RELEASE_11; 182 } 183 184 private static final SourceVersion latestSupported = getLatestSupported(); 185 186 private static SourceVersion getLatestSupported() { 187 try { 188 String specVersion = System.getProperty("java.specification.version"); 189 190 switch (specVersion) { 191 case "11": 192 return RELEASE_11; 193 case "10": 194 return RELEASE_10; 195 case "9": 196 return RELEASE_9; 197 case "1.8": 198 return RELEASE_8; 199 case "1.7": 200 return RELEASE_7; 201 case "1.6": 202 return RELEASE_6; 203 } 204 } catch (SecurityException se) {} 205 206 return RELEASE_5; 207 } 208 209 /** 210 * Returns the latest source version fully supported by the 211 * current execution environment. {@code RELEASE_5} or later must 212 * be returned. |