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