8274670: Improve version string handling in SA
Reviewed-by: cjplummer, sspitsyn
This commit is contained in:
parent
df7b0c7077
commit
986ee5d0bf
@ -359,26 +359,26 @@ public class VM {
|
||||
if (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null) {
|
||||
// read sa build version.
|
||||
String versionProp = "sun.jvm.hotspot.runtime.VM.saBuildVersion";
|
||||
String saVersion = saProps.getProperty(versionProp);
|
||||
if (saVersion == null)
|
||||
String versionPropVal = saProps.getProperty(versionProp);
|
||||
if (versionPropVal == null) {
|
||||
throw new RuntimeException("Missing property " + versionProp);
|
||||
}
|
||||
|
||||
// Strip nonproduct VM version substring (note: saVersion doesn't have it).
|
||||
String vmVersion = vmRelease.replaceAll("(-fastdebug)|(-debug)|(-jvmg)|(-optimized)|(-profiled)","");
|
||||
var saVersion = Runtime.Version.parse(versionPropVal);
|
||||
var vmVersion = Runtime.Version.parse(vmRelease);
|
||||
|
||||
if (saVersion.equals(vmVersion)) {
|
||||
// Exact match
|
||||
return;
|
||||
}
|
||||
if (saVersion.indexOf('-') == saVersion.lastIndexOf('-') &&
|
||||
vmVersion.indexOf('-') == vmVersion.lastIndexOf('-')) {
|
||||
if (!saVersion.equalsIgnoreOptional(vmVersion)) {
|
||||
// Throw exception if different release versions:
|
||||
// <major>.<minor>-b<n>
|
||||
throw new VMVersionMismatchException(saVersion, vmRelease);
|
||||
// <version>+<build>
|
||||
throw new VMVersionMismatchException(saVersion, vmVersion);
|
||||
} else {
|
||||
// Otherwise print warning to allow mismatch not release versions
|
||||
// during development.
|
||||
System.err.println("WARNING: Hotspot VM version " + vmRelease +
|
||||
System.err.println("WARNING: Hotspot VM version " + vmVersion +
|
||||
" does not match with SA version " + saVersion +
|
||||
"." + " You may see unexpected results. ");
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ package sun.jvm.hotspot.runtime;
|
||||
/** An instance of this exception is thrown when debuggee VM version
|
||||
is not supported current version of SA. */
|
||||
public class VMVersionMismatchException extends RuntimeException {
|
||||
public VMVersionMismatchException(String supported, String target) {
|
||||
public VMVersionMismatchException(Runtime.Version supported, Runtime.Version target) {
|
||||
super();
|
||||
supportedVersions = supported;
|
||||
targetVersion = target;
|
||||
@ -38,14 +38,14 @@ public class VMVersionMismatchException extends RuntimeException {
|
||||
". Target VM is " + targetVersion;
|
||||
}
|
||||
|
||||
public String getSupportedVersions() {
|
||||
public Runtime.Version getSupportedVersions() {
|
||||
return supportedVersions;
|
||||
}
|
||||
|
||||
public String getTargetVersion() {
|
||||
public Runtime.Version getTargetVersion() {
|
||||
return targetVersion;
|
||||
}
|
||||
|
||||
private String supportedVersions;
|
||||
private String targetVersion;
|
||||
private final Runtime.Version supportedVersions;
|
||||
private final Runtime.Version targetVersion;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user