JDK-8274670 : Improve version string handling in SA
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 9,11,17,18
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2021-10-03
  • Updated: 2021-10-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18Unresolved
Related Reports
Relates :  
Description
Use java.lang.Runtime.Version to check the version of debugee.

Currently `checkVMVersion()` in `sun.jvm.hotspot.runtime.VM` has following code to check the version of debugee.

```
        if (saVersion.indexOf('-') == saVersion.lastIndexOf('-') &&
            vmVersion.indexOf('-') == vmVersion.lastIndexOf('-')) {
           // Throw exception if different release versions:
           // <major>.<minor>-b<n>
           throw new VMVersionMismatchException(saVersion, vmRelease);
        } else {
           // Otherwise print warning to allow mismatch not release versions
           // during development.
           System.err.println("WARNING: Hotspot VM version " + vmRelease +
                              " does not match with SA version " + saVersion +
                              "." + " You may see unexpected results. ");
        }
```

It seems to expect to allow the deference in option string only.
For example, saVersion is "17+35", and vmVersion is "17+35-2724", then it should be allowed because release version (17+35) is same. However current code would not do so.

I guess this code is not based on JEP 223 (New Version-String Scheme) because the comment says "<major>.<minor>-b<n>". Fortunately we have `Runtime.Version` to handle version strings. We should refactor with it.