JDK-8242162 : convert clhsdb "sysprops" command from javascript to java
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: svc-agent
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-04
  • Updated: 2020-04-16
  • Resolved: 2020-04-09
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 15
15 b19Fixed
Related Reports
Relates :  
Description
This one looks to be trival:

    this.sysProps = function() {
      for (var i in jvm.sysProps) {
         writeln(i + ' = ' + jvm.sysProps[i]);
      }
    }
    registerCommand("sysprops", "sysprops", "sysProps");

jvm.sysProps[] is a cache initialized on the java side by the following:

    private synchronized JSMap getSysProps() {
        if (sysPropsCache == null) {
            Properties props = vm.getSystemProperties();
            Map map = new HashMap();
            if (props != null) {
                Enumeration e = props.propertyNames();
                while (e.hasMoreElements()) {
                    String key = (String) e.nextElement();
                    map.put(key, props.getProperty(key));
                }
            }
            sysPropsCache = factory.newJSMap(map);
        }
        return sysPropsCache;
    }

We don't need to keep a cache, so the implementation can be a similar loop to what is in getSysProps(), but just printing the key+value rather than caching it.

Output from old javascript sysprops command looks like the following:

awt.toolkit = sun.awt.X11.XToolkit 
file.encoding.pkg = sun.io 
java.specification.version = 1.8 
...
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/49baadd53e06 User: cjplummer Date: 2020-04-09 14:15:45 +0000
09-04-2020