Collect thread dumps of all Java process on localhost
Mandy Chung
mandy.chung at oracle.com
Thu Nov 5 00:02:02 UTC 2015
> On Nov 4, 2015, at 2:32 PM, Keimpe Bronkhorst <keimpe.bronkhorst at oracle.com> wrote:
>
> This concerns code we have in Oracle JDeveloper which collect thread dumps of all Java Processes on local host. This code uses the non-public JDK classes:
> import sun.jvmstat.monitor.MonitorException;
> import sun.jvmstat.monitor.MonitoredHost;
> import sun.jvmstat.monitor.MonitoredVm;
> import sun.jvmstat.monitor.MonitoredVmUtil;
> import sun.jvmstat.monitor.VmIdentifier;
>
> to identify the Java processes on local host, and
>
> import com.sun.tools.attach.VirtualMachine;
> import sun.tools.attach.HotSpotVirtualMachine;
>
> to attach to the processes and dump their threads.
>
> The trouble is that these classes are not accessible anymore in JDK9 unless -XaddExports: is used.
>
> Does anybody know how to do this functionality using public classes, or are there plans to add public classes to replace these non-public classes?
com.sun.tools.attach is supported API that you should use to list the VM processes on a local host:
http://download.java.net/jdk9/docs/jdk/api/attach/spec/index.html
I guess you are calling HotSpotVirtualMachine.remoteDataDump method to get thread dump. Can you use java.lang.management.ThreadMXBean.dumpAllThreads once you start a local JMX agent in the attached VM?
Mandy
More information about the serviceability-dev
mailing list