Extend jcmd to java application level

David Holmes david.holmes at oracle.com
Fri Oct 8 01:25:18 UTC 2021


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 through `jcmd`?
> 
> One application scenario I can think of for this extension is that some statistical information
> may be collected in a java application. Triggering the output of this statistical information through
> the `jcmd` command seems to me relative to other mechanisms that trigger output (such as through
> an HTTP service, or periodic Printing) is more convenient.
> 
> Any input is appreciated.

If the intent is that you could issue a jcmd:

jcmd <vmid> MyClass.foo

to have it run/use a Java thread to execute arbitrary code then I think 
a lot of careful consideration would need to be given to making this 
facility safe and secure. I can easily imagine that the thread used, and 
the timing, could cause failures. Executing arbitrary code may be far 
too general, so it might mean we need a new "service" interface defined 
that the target class has to implement.

It might well be useful but will need some deep thought IMO.

Cheers,
David

> Thanks,
> Denghui Dong


More information about the hotspot-runtime-dev mailing list