equal
deleted
inserted
replaced
24 */ |
24 */ |
25 |
25 |
26 package jdk; |
26 package jdk; |
27 |
27 |
28 import java.math.BigInteger; |
28 import java.math.BigInteger; |
29 import java.security.AccessController; |
|
30 import java.security.PrivilegedAction; |
|
31 import java.util.ArrayList; |
29 import java.util.ArrayList; |
32 import java.util.regex.Matcher; |
30 import java.util.regex.Matcher; |
33 import java.util.regex.Pattern; |
31 import java.util.regex.Pattern; |
34 import java.util.stream.Collectors; |
32 import java.util.stream.Collectors; |
35 import java.util.Collections; |
33 import java.util.Collections; |
36 import java.util.List; |
34 import java.util.List; |
37 import java.util.Optional; |
35 import java.util.Optional; |
|
36 import sun.security.action.GetPropertyAction; |
38 |
37 |
39 /** |
38 /** |
40 * A representation of the JDK version-string which contains a version |
39 * A representation of the JDK version-string which contains a version |
41 * number optionally followed by pre-release and build information. |
40 * number optionally followed by pre-release and build information. |
42 * |
41 * |
272 * |
271 * |
273 * @return {@code System.getProperty("java.version")} as a Version |
272 * @return {@code System.getProperty("java.version")} as a Version |
274 */ |
273 */ |
275 public static Version current() { |
274 public static Version current() { |
276 if (current == null) { |
275 if (current == null) { |
277 current = parse(AccessController.doPrivileged( |
276 current = parse(GetPropertyAction.getProperty("java.version")); |
278 new PrivilegedAction<>() { |
|
279 public String run() { |
|
280 return System.getProperty("java.version"); |
|
281 } |
|
282 })); |
|
283 } |
277 } |
284 return current; |
278 return current; |
285 } |
279 } |
286 |
280 |
287 /** |
281 /** |