< prev index next >
jdk/src/java.base/share/classes/sun/misc/Version.java.template
Print this page
*** 53,71 ****
private static boolean versionsInitialized = false;
private static int jvm_major_version = 0;
private static int jvm_minor_version = 0;
private static int jvm_security_version = 0;
! private static int jvm_update_version = 0;
private static int jvm_build_number = 0;
- private static String jvm_special_version = null;
private static int jdk_major_version = 0;
private static int jdk_minor_version = 0;
private static int jdk_security_version = 0;
! private static int jdk_update_version = 0;
private static int jdk_build_number = 0;
- private static String jdk_special_version = null;
/**
* In case you were wondering this method is called by java -version.
* Sad that it prints to stderr; would be nicer if default printed on
* stdout.
--- 53,69 ----
private static boolean versionsInitialized = false;
private static int jvm_major_version = 0;
private static int jvm_minor_version = 0;
private static int jvm_security_version = 0;
! private static int jvm_patch_version = 0;
private static int jvm_build_number = 0;
private static int jdk_major_version = 0;
private static int jdk_minor_version = 0;
private static int jdk_security_version = 0;
! private static int jdk_patch_version = 0;
private static int jdk_build_number = 0;
/**
* In case you were wondering this method is called by java -version.
* Sad that it prints to stderr; would be nicer if default printed on
* stdout.
*** 144,191 ****
return jvm_minor_version;
}
/**
! * Returns the security version of the running JVM if it's 1.6 or newer
! * or any RE VM build. It will return 0 if it's an internal 1.5 or
! * 1.4.x build.
* @since 1.6
*/
public static synchronized int jvmSecurityVersion() {
if (!versionsInitialized) {
initVersions();
}
return jvm_security_version;
}
/**
! * Returns the update release version of the running JVM if it's
! * a RE build. It will return 0 if it's an internal build.
! * @since 1.6
*/
! public static synchronized int jvmUpdateVersion() {
if (!versionsInitialized) {
initVersions();
}
! return jvm_update_version;
}
- public static synchronized String jvmSpecialVersion() {
- if (!versionsInitialized) {
- initVersions();
- }
- if (jvm_special_version == null) {
- jvm_special_version = getJvmSpecialVersion();
- }
- return jvm_special_version;
- }
- public static native String getJvmSpecialVersion();
-
/**
! * Returns the build number of the running JVM if it's a RE build
! * It will return 0 if it's an internal build.
* @since 1.6
*/
public static synchronized int jvmBuildNumber() {
if (!versionsInitialized) {
initVersions();
--- 142,174 ----
return jvm_minor_version;
}
/**
! * Returns the security version of the running JVM
* @since 1.6
*/
public static synchronized int jvmSecurityVersion() {
if (!versionsInitialized) {
initVersions();
}
return jvm_security_version;
}
/**
! * Returns the patch release version of the running JVM
! * @since JDK9
*/
! public static synchronized int jvmPatchVersion() {
if (!versionsInitialized) {
initVersions();
}
! return jvm_patch_version;
}
/**
! * Returns the build number of the running JVM
* @since 1.6
*/
public static synchronized int jvmBuildNumber() {
if (!versionsInitialized) {
initVersions();
*** 226,336 ****
}
return jdk_security_version;
}
/**
! * Returns the update release version of the running JDK if it's
! * a RE build. It will return 0 if it's an internal build.
! * @since 1.6
*/
! public static synchronized int jdkUpdateVersion() {
if (!versionsInitialized) {
initVersions();
}
! return jdk_update_version;
}
- public static synchronized String jdkSpecialVersion() {
- if (!versionsInitialized) {
- initVersions();
- }
- if (jdk_special_version == null) {
- jdk_special_version = getJdkSpecialVersion();
- }
- return jdk_special_version;
- }
- public static native String getJdkSpecialVersion();
-
/**
! * Returns the build number of the running JDK if it's a RE build
! * It will return 0 if it's an internal build.
* @since 1.6
*/
public static synchronized int jdkBuildNumber() {
if (!versionsInitialized) {
initVersions();
}
return jdk_build_number;
}
- // true if JVM exports the version info including the capabilities
- private static boolean jvmVersionInfoAvailable;
private static synchronized void initVersions() {
if (versionsInitialized) {
return;
}
! jvmVersionInfoAvailable = getJvmVersionInfo();
! if (!jvmVersionInfoAvailable) {
! // parse java.vm.version for older JVM before the
! // new JVM_GetVersionInfo is added.
! // valid format of the version string is:
! // n.n.n[_uu[c]][-<identifer>]-bxx
! CharSequence cs = System.getProperty("java.vm.version");
! if (cs.length() >= 5 &&
! Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' &&
! Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' &&
! Character.isDigit(cs.charAt(4))) {
! jvm_major_version = Character.digit(cs.charAt(0), 10);
! jvm_minor_version = Character.digit(cs.charAt(2), 10);
! jvm_security_version = Character.digit(cs.charAt(4), 10);
! cs = cs.subSequence(5, cs.length());
! if (cs.charAt(0) == '_' && cs.length() >= 3 &&
! Character.isDigit(cs.charAt(1)) &&
! Character.isDigit(cs.charAt(2))) {
! int nextChar = 3;
! try {
! String uu = cs.subSequence(1, 3).toString();
! jvm_update_version = Integer.valueOf(uu).intValue();
! if (cs.length() >= 4) {
! char c = cs.charAt(3);
! if (c >= 'a' && c <= 'z') {
! jvm_special_version = Character.toString(c);
! nextChar++;
! }
! }
! } catch (NumberFormatException e) {
! // not conforming to the naming convention
! return;
! }
! cs = cs.subSequence(nextChar, cs.length());
! }
! if (cs.charAt(0) == '-') {
! // skip the first character
! // valid format: <identifier>-bxx or bxx
! // non-product VM will have -debug|-release appended
! cs = cs.subSequence(1, cs.length());
! String[] res = cs.toString().split("-");
! for (String s : res) {
! if (s.charAt(0) == 'b' && s.length() == 3 &&
! Character.isDigit(s.charAt(1)) &&
! Character.isDigit(s.charAt(2))) {
! jvm_build_number =
! Integer.valueOf(s.substring(1, 3)).intValue();
! break;
! }
! }
! }
! }
}
getJdkVersionInfo();
versionsInitialized = true;
}
// Gets the JVM version info if available and sets the jvm_*_version fields
// and its capabilities.
- //
- // Return false if not available which implies an old VM (Tiger or before).
private static native boolean getJvmVersionInfo();
private static native void getJdkVersionInfo();
}
// Help Emacs a little because this file doesn't end in .java.
--- 209,252 ----
}
return jdk_security_version;
}
/**
! * Returns the patch release version of the running JDK
! * @since JDK9
*/
! public static synchronized int jdkPatchVersion() {
if (!versionsInitialized) {
initVersions();
}
! return jdk_patch_version;
}
/**
! * Returns the build number of the running JDK
* @since 1.6
*/
public static synchronized int jdkBuildNumber() {
if (!versionsInitialized) {
initVersions();
}
return jdk_build_number;
}
private static synchronized void initVersions() {
if (versionsInitialized) {
return;
}
! if (!getJvmVersionInfo()) {
! throw new RuntimeException("Unable to obtain JVM version info");
}
getJdkVersionInfo();
versionsInitialized = true;
}
// Gets the JVM version info if available and sets the jvm_*_version fields
// and its capabilities.
private static native boolean getJvmVersionInfo();
private static native void getJdkVersionInfo();
}
// Help Emacs a little because this file doesn't end in .java.
< prev index next >