@author mbechler
| 5 | * @author mbechler |
| 6 | */ |
| 7 | public class JavaVersion { |
| 8 | |
| 9 | |
| 10 | public int major; |
| 11 | public int minor; |
| 12 | public int update; |
| 13 | |
| 14 | |
| 15 | public static JavaVersion getLocalVersion() { |
| 16 | String property = System.getProperties().getProperty("java.version"); |
| 17 | if (property == null) { |
| 18 | return null; |
| 19 | } |
| 20 | JavaVersion v = new JavaVersion(); |
| 21 | String parts[] = property.split("\\.|_|-"); |
| 22 | int start = "1".equals(parts[0]) ? 1 : 0; // skip "1." prefix |
| 23 | v.major = Integer.parseInt(parts[start + 0]); |
| 24 | v.minor = Integer.parseInt(parts[start + 1]); |
| 25 | v.update = Integer.parseInt(parts[start + 2]); |
| 26 | return v; |
| 27 | } |
| 28 | |
| 29 | public static boolean isAnnInvHUniversalMethodImpl() { |
| 30 | JavaVersion v = JavaVersion.getLocalVersion(); |
| 31 | return v != null && (v.major < 8 || (v.major == 8 && v.update <= 71)); |
| 32 | } |
| 33 | |
| 34 | public static boolean isBadAttrValExcReadObj() { |
| 35 | JavaVersion v = JavaVersion.getLocalVersion(); |
| 36 | return v != null && (v.major > 8 && v.update >= 76); |
| 37 | } |
| 38 | |
| 39 | public static boolean isAtLeast(int major) { |
| 40 | JavaVersion v = JavaVersion.getLocalVersion(); |
| 41 | return v != null && v.major >= major; |
| 42 | } |
| 43 | } |
| 44 |
nothing calls this directly
no outgoing calls
no test coverage detected