JDK-4375402 : Add ability to obtain full thread dump programmatically
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 1.3.0,1.3.1,1.4.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS:
    generic,solaris_8,windows_nt,windows_2000 generic,solaris_8,windows_nt,windows_2000
  • CPU: generic,x86,sparc
  • Submitted: 2000-10-01
  • Updated: 2002-08-01
  • Resolved: 2002-08-01
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description

Name: krC82822			Date: 10/01/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

It would be extremely useful to be able to obtain a full thread dump
programmatically, e.g. by adding a method to java.lang.Runtime to return what
otherwise can only be obtained by a Ctrl-C (SIGINT) in the console window.
If the production version of our application hangs, we have no way of sending
it an interrupt to obtain the thread dump.  But we can add code to the
application to get the dump on demand (say from a troubleshooting menu).

For ease of parsing, it would be most convenient if:
(a) each thread's stack backtrace was returned separately, either as a String
or a custom class object;
(b) each monitor in the monitor cache dump was returned separately, either as a
String or custom class object.

Looking at the JVM code, I can see that the String return values would be
easier.  Returning an array of Strings would be sufficient.

Alternatively, perhaps an OutputStream could be supplied to the method and the
thread dump written to the stream.
(Review ID: 109991) 
======================================================================

Comments
PUBLIC COMMENTS .
10-06-2004

EVALUATION This is a reasonable request, though it might best be addressed through the special purpose debugging APIs (JVMPI/JVMDI/etc.). If we do add calls to perform this function, they should not return mere strings, but structured information, in the mannger Thread.getStackTrace(). joshua.bloch@Eng 2001-07-29 I'm closing this RFE as a dup of 4593133 which is currently tracked as a Tiger feature. ###@###.### 2002-08-01
29-07-2001