Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java debugging - watch an out of scope variable

When debugging a C/C++ application I can create a watch of an address cast to a pointer type and then view that contents of a structure even when it goes out of scope. Is it possible to achieve something like that in Java?
Let's say I'm in a method, I add a watch to something like "&this" and then when I leave the class method I can still see its contents even though it is out of scope?

I'm pretty sure the answer to my question is "no" so I'm mostly interested in "Why not?" explanation. Is this a JVM limitation? A JPDA limitation? Is there a better place to ask such a specialized question?

like image 951
MK. Avatar asked Sep 13 '11 02:09

MK.


1 Answers

In C/C++ you are watching (the area pointed to by) an arbitrary pointer, casting to that variable.

In Java there are no pointers. You can only watch a variable. Out of scope it does not exist.

Why would you want to watch it anyway? If you put a watch on it, it is watched properly when in scope.

like image 96
Miserable Variable Avatar answered Oct 22 '22 14:10

Miserable Variable