JDK-8262162 : add new attach API command dumpheapext for passing more options to jvm
  • Type: CSR
  • Component: tools
  • Priority: P4
  • Status: Closed
  • Resolution: Withdrawn
  • Fix Versions: 17
  • Submitted: 2021-02-23
  • Updated: 2021-04-14
  • Resolved: 2021-04-14
Related Reports
CSR :  
Description
Summary
-------

Introduce the attach API command - `dumpheapext` to accept more arguments for jmap alike tools. This command is an extension of `dumpheap` command for argument processing and it is not exposed to user. 

Problem
-------

The implementation of attach API used by jcmd tools like `jmap` has a limitation that the arguments number could not exceed 3. 

To overcome this limitation, both jmap command and the JVM(attachListener) need to be modified to change the way that arguments are transported and parsed. (e.g. The jmap compose all arguments into a single string, and let JVM parse it to get every argument) 

But this change could causes compatibility issue when new argument like "parallel=" was introduced to `jmap -dump` command, which makes `jmap -dump` have 4 arguments. 

The issue is that old version of JVM could not parse the arguments from new version of jmap.

Solution
--------

To solve the issue, it is proposed to add an internal attach API command - `dumpheapext`, which first test whether there is new argument added (like `parallel=` for jmap dump): 

If No, it calls dumpheap and works as before.

If Yes, it composes the whole argument as a string and pass it to JVM, and if JVM can not accept and thrown exception of "heapdumpext" is not recognized, it is an old version of JVM, and the jmap eats that exception and print error message like "unknow argument", which behaves like the old version of jmap.

Specification
------

No changes are required for specification. Because the proposed "dumpheapext" command is not exposed to user. And user should not be aware of it from any kind of output prompted by Jmap command.

Comments
As discussed in https://github.com/openjdk/jdk/pull/2261. It is hard for user to tune the thread number used for parallel heap dump. So we decide not to expose the `parallel=<N>`option for jmap -dump. And hence there is no need to extend jcmd internal command at present. Close this issue and related CSR, it could be reopened when there is new requirement for adding more arguments to jcmd jmap command. Thanks.
14-04-2021

Moving to Provisional, not Approved. Please add the required Specification section and get one or more reviewers before this request is Finalized for the second round of CSR review.
24-02-2021