JDI problem - can't get frame stack for sleeping threads

Hi,

I have added a button to our Swing application that lets me get a complete thread dump of our application - I do this by starting the app via JDI and adding a breakpoint on a specific type of exception, which is then deliberately thrown when I press the button. The breakpoint has a suspend policy of SUSPEND_ALL.

This almost works - but for some reason, back in my 'debugger' class,some of the ThreadReference objects for my app give an exception when I try to get their frame stack. Here's an extract of my code:for (Iterator it = vm.allThreads ().iterator (); it.hasNext ();){

ThreadReference tr = (ThreadReference) it.next ();

List frames;

try{

frames = tr.frames ();

}catch (IncompatibleThreadStateException e){

System.err.println ("Oops - " + tr.name () +" is suspended " + tr.isSuspended ());

continue;

}

}

Guess what? I end up seeing lines like "Oops - Thread 1 is suspended true". How can this be?

Using the native stack dump (kill -QUIT) I found that the threads that were exhibiting this behaviour were threads that were in java.lang.Thread.sleep. Can anybody explain why this is and what I can do about it?

Thanks,

R

PS This is RH linux 9.0 - I get the same behaviour with 1.4.1_02-b06 and 1.4.2_02-b03

[1675 byte] By [RGibsona] at [2007-9-29 14:27:06]
# 1
HelloThis is a case of Bug ID 4783403Synopsis: JDI ThreadReference.frameCount() fails when thread is sleeping http://developer.java.sun.com/developer/bugParade/bugs/4783403.html
debugging_teama at 2007-7-15 5:10:41 > top of Java-index,Archived Forums,Debugging Tools and Techniques...
# 2

hi!! we have started working on our project which aims to migrate the thread from one machine to other.. for doin so we are using JDI for capturing the state of the thread.. can u kindly devise a way to connect JDI program to the required application.., the following fragment of code will make things clear

1.VirtualMachine vm=.....

2.for (Iterator it = vm.allThreads ().iterator (); it.hasNext ();) {ThreadReference tr = (ThreadReference) it.next ();}

focus on line one of the code what value we r supposed to set for "vm"

thanx

rahul_hmka at 2007-7-15 5:10:41 > top of Java-index,Archived Forums,Debugging Tools and Techniques...
# 3

hi!! we have started working on our project which aims to migrate the thread from one machine to other.. for doin so we are using JDI for capturing the state of the thread.. can u kindly devise a way to connect JDI program to the required application.., the following fragment of code will make things clear

1.VirtualMachine vm=.....

2.for (Iterator it = vm.allThreads ().iterator (); it.hasNext ();) {ThreadReference tr = (ThreadReference) it.next ();}

focus on line one of the code what value we r supposed to set for "vm"

thanx

rahul_hmka at 2007-7-15 5:10:41 > top of Java-index,Archived Forums,Debugging Tools and Techniques...