On Mar 15, 7:20 pm, Mark Space <marksp...@sbc.global.net> wrote:
ash wrote:
Hello ,
I have just been introduced to java reflection , and i understand i
could reflect Classes basic information like methods, constructors,
and fields. But i would like to further reflect local variables ( say
local variables in methods). How could i do that with java reflection
api ? If it cant be done using java reflection api a hint about how it
could be done would be greatly appreciated :D
Local variables don't belong to classes, they belong to threads. You'd
need some sort of stack trace or thread dump to access local variables.
I don't see such a facility in the Thread classs.
JMX might get you what you want. It is basically a "debugger" tool,
allowing you to poke at a running JVM and it's application.
<http://java.sun.com/docs/books/tutorial/jmx/overview/index.html>
<http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement...>
Thanx for your reply , but i have 2 questions for you though. What do
you mean local variables belong to threads ? If i am write a new class
and im defining some variables , methods or any other stuff. these
elements belong to this class. And second Im checking out JMX now but
it looks too complicated for what i want to accomplish. What i need is
an API to access a running Class information ( methods, fields, local
variables, while loops, for loops , any other thing defined in that
class).
to method activations. Every method activation happens in some thread.
same method in the same thread. There is a set of local variables for
each activation.
operation, processing stack frames, rather than as reflection.