thank you very much for your reply first
In Jbuilder, when i press the program, jbuilder can auto detect
which variable in your current scope and print the value of them. I
want to do the same thing.
thanks
from Peter
halfdog - 11 May 2006 09:51 GMT
I have posted a similar problem, but I also wanted to get all
variables, from all threads. As it seems there is no solution from
within java, only the debugger can examine the stack. No automated
solutions seem to be available. See comp.lang.java.programmer: "Dump
complete java VM state as core dump (not via OS) possible?"
http://groups.google.at/group/comp.lang.java.programmer/browse_frm/thread/a61370
569e550bbe/5bdd61b05f8e3c09?lnk=arm#5bdd61b05f8e3c09
Chris Uppal - 11 May 2006 10:58 GMT
> In Jbuilder, when i press the program, jbuilder can auto detect
> which variable in your current scope and print the value of them. I
> want to do the same thing.
You can't unless you are willing to use the JVMTI interfaces that the debugger
uses. Note that those interfaces are for /other/ processes (e.g. a debugger)
to use, and cannot (reliably) be used by a program on itself.
I.e. it's not really possible.
-- chris
halfdog - 11 May 2006 16:02 GMT
Good tip, but it is really bad that you are right with your post: I
looked at the JPDA interfaces and its not quite easy. The packets to
retrieve stack-traces are moderately complex, but as I see it, there is
no other means to retrieve a list of all instanciated objects, then to
start from all threads and loop over all references to collect
everything that is reachable.
I've also sent a request to the java-soft product help desk asking
these questions, lets see what they say about it.
Stefan Schulz - 11 May 2006 12:05 GMT
This seems to be some kind of interface to the debugger JBuilder
(presumably) bundles. This is not possible (AFAIK) if running outside
of a debugger.