Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8240987

Implement lost clhsdb javascript commands by using java instead

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 19
    • Component/s: hotspot
    • Labels:
      None

      Description

      JDK-8235594 documents issues with the SA javascript support (which is most apparent in clhsdb). Since the javascript support no longer works, it has been disabled and will soon be removed. As a result we have lost the following clhsdb commands, which were implemented in javascript:

      class
      classes
      dumpclass
      dumpheap
      mem
      sysprops
      whatis

      It would be nice to bring as many of these back as possible by implementing them in java. For some, such as dumpheap and dumpclass, the work is trivial since the only thing the javascript side of the command is doing is invoking some existing java code. We can instead just have a regular clhsdb command (written in java) do the same. I've was easily able to do this for dumpheap already with just a few minutes of work. Other commands will be much more of a challenge since they have a lot of javascript supporting them, and may not be worth the effort.

      sa.js is where you will find the javascript implementation of these commands. You'll see something like the following for each command:

          registerCommand("dumpheap", "dumpheap [ file ]", "dumpHeap");

      The 3rd argument is the implementation. It can either be a javascript method in the sa.js file, or it can be a java method in JSJavaScriptEngine.java. For dumpHeap it is the latter, and the implementation is simple:

          public Object dumpHeap(Object[] args) {
              String fileName = "heap.bin";
              if (args.length > 0) {
                  fileName = args[0].toString();
              }
              return new JMap().writeHeapHprofBin(fileName)? Boolean.TRUE: Boolean.FALSE;
          }

      It is very easy to move this code into CommandProcessor.java as a new Command in commandList[].

      This CR will be used as a parent CR for each command we want to implement in java, which will be handled in subtasks. We can close this CR when all of the have been implemented or determined to not be worth the effort.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cjplummer Chris Plummer
              Reporter:
              cjplummer Chris Plummer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: