If you do not want to copy the TDA code (after all, this is the LGPL), you can also use the Attach API to retrieve data in a standard format. As far as I know, the only built-in JVM code for dumping is Attach's own agent code.
String selfName = ManagementFactory.getRuntimeMXBean().getName(); final int selfPid = Integer.valueOf(selfName.substring(0, selfName.indexOf('@'))); HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine.attach(Integer.toString(selfPid)); InputStream sDump = vm.remoteDataDump(new Object[]{"-l"});
A data dump will return a dump to the character data stream.
source share