JavaVersion.java
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Decompiled with CFR 0_118.
*/
package com.day.util;
import java.net.URL;
public class JavaVersion {
private static final Package specPackage = new ClassLoader(){
Package createPackage() {
return this.definePackage("dummy.package", System.getProperty("java.specification.name"), System.getProperty("java.specification.version"), System.getProperty("java.specification.vendor"), "Java Runtime Environment", System.getProperty("java.version"), System.getProperty("java.vendor"), null);
}
}.createPackage();
private static final String specVersion13 = "1.3";
private static final String specVersion14 = "1.4";
private static final String specVersion15 = "1.5";
private JavaVersion() {
}
public static String getVersion() {
return specPackage.getImplementationVersion();
}
public static String getSpecificationVersion() {
return specPackage.getSpecificationVersion();
}
public static boolean is13() {
return JavaVersion.isSpecificationVersion("1.3");
}
public static boolean is14() {
return JavaVersion.isSpecificationVersion("1.4");
}
public static boolean is15() {
return JavaVersion.isSpecificationVersion("1.5");
}
public static boolean isSpecificationVersion(String specVersion) {
if (specVersion == null || specVersion.length() == 0) {
return false;
}
return specVersion.equals(JavaVersion.getSpecificationVersion());
}
public static boolean isCompatibleWith13() {
return JavaVersion.isCompatibleWith("1.3");
}
public static boolean isCompatibleWith14() {
return JavaVersion.isCompatibleWith("1.4");
}
public static boolean isCompatibleWith15() {
return JavaVersion.isCompatibleWith("1.5");
}
public static boolean isCompatibleWith(String specVersion) {
return specPackage.isCompatibleWith(specVersion);
}
}