views:

66

answers:

1

I always thought that varibales are mapped to stack locations once your Java source is compiled; additionally, they may include the info about the variable names and their scope in classfiles, but that's optional AFAIK.

The question is - how do my Eclipse/IDEA IDEs allow me to set a watch expression containing the local variable name? To me, it's hard to understand :)

+3  A: 

All those IDE base their debug services on top of the JavaTM Platform Debugger Architecture (JPDA).
More precisely, they are all using the Java Virtual Machine Tool Interface (JVM TI), which replaced from JDK5 the experimental JVMPI (Java Virtual Machine Profiling Interface).

That JVMTI includes a Watched Field function and a SetFieldModificationWatch function.

But that doesn't include local variable: there is actually an RFE opened since quite some time now: bug 4228507.
So in the case of local variable, chances are some kind of BCI is used (Byte Code Instrumentation) (like the TPTP Eclipse module does).

VonC
Local vars are fields? Really?
Bubba88
@Bubba88: I agree, that doesn't include local vars. I suppose custom BCI agents are associated with the debug session to wrap those local vars in method call, to be able to watch them. I have completed my answer with some references, but nothing yet definitive.
VonC