Re: Extend jcmd to java application level

2021-10-08 Thread Denghui Dong
Hi, Thank you for the response. I just made a PoC for this extension: https://github.com/D-D-H/jdk/commit/eb2a13b7ba8bd3e6d048491c8a579b179d2cef0d Here is the test code: ``` import sun.management.cmd.CmdMeta; import sun.management.cmd.Command; import sun.management.cmd.ParamMeta; import sun.man

Re: Extend jcmd to java application level

2021-10-08 Thread Erik Gahlin
To make an application command usable, it must provide metadata (name and description of the command, its options’ data types, units, default values, if it is mandatory etc.) and error handling. This will make the API surface larger and trickier to get right. (Not a full overlap, but we are thi

Re: Extend jcmd to java application level

2021-10-08 Thread Yi Yang
That seems an ideal solution. I think there are some potential code consolidation work further. With this change, some existing C++ JFR Jcmd structure definitions(and other Jcmd commands) in VM level can also be lifted to Java level because they simply forward request to Java level by JavaCalls

Re: Extend jcmd to java application level

2021-10-08 Thread Ioi Lam
On 10/7/21 6:25 PM, David Holmes wrote: Hi Denghui, On 7/10/2021 11:58 pm, Denghui Dong wrote: Hi team, The `jcmd` command can be used to call some built-in diagnostic commands in vm. Can we consider extending it to the java layer like perf data, so that Java developers can customize t

Re: Extend jcmd to java application level

2021-10-07 Thread Yasumasa Suenaga
Hi Denghui, I thought to add JMX client feature to jcmd in the past for similar purposes, but I didn't because JMX URL is too complex to type into console :) Your proposal is useful, but it means malicious users can inject arbitrary code. I think we need to consider security, and existing fram

Re: Extend jcmd to java application level

2021-10-07 Thread David Holmes
Hi Denghui, On 7/10/2021 11:58 pm, Denghui Dong wrote: Hi team, The `jcmd` command can be used to call some built-in diagnostic commands in vm. Can we consider extending it to the java layer like perf data, so that Java  developers can customize their diagnostic commands and then call them thro

Re: Extend jcmd to java application level

2021-10-07 Thread Denghui Dong
Hi Yasumasa, JVMTI.data_dump and DataDumpRequest can achieve the purpose of triggering. IIUC, DataDumpRequest does not seem to be able to pass parameters. And sometimes the action the user wants to trigger may not be a data dump. In fact, I think that commands such as JFR.start/stop are such a m

Re: Extend jcmd to java application level

2021-10-07 Thread Yasumasa Suenaga
Hi Denghui, I think you can do it with combination of JVMTI.data_dump dcmd and DataDumpRequest event in JVMTI. JVM(TM) Tool Interface 17.0.0 (oracle.com) Thanks, Yasumasa On 2021/10/07 22:58, Denghui Dong