views:

257

answers:

3

I'm wondering if there is a way to look at the values of non-declared variables as they get passed into a function, after that function has been executed. For example, if I am debugging and the line

foo.setBar(baz.getBar());

has already been passed (but is still within scope), how can I see the value of what got passed in to setBar()? I know that I can see this many other ways, for instance by stepping into the setBar() call, or by assigning baz.getBar() to a temporary variable - but that's not what I'm asking.

Edit: Basically, I feel penalized (by losing the ability to see certain information) while debugging, just because I'm not declaring every variable.

And, I know I could inspect bar after the fact (if I know it hadn't changed) but in this case it's not so simple because I'm dealing with objects that aren't just POJOs or JavaBeans (the object that brought this question up is an HTTP request - and yes, I already did try inspecting it).

+3  A: 

In the Debug perspective, open the display window (Window => Show View => Display), write the code that you want to display (e.g., baz.getBar()), select it, and then right click and choose "Display" or use the shortcut to display its value.

JG
Almost - I had to select the text I wanted to execute first. Thank you! I never knew about that view.
Matt Ball
Yes, coming from Visual Studio and its similar Immediate Window, I also forgot to select the text the first time I used it : P.
JG
+1  A: 

And of course you can use "Expressions" view (Window -> Show View -> Expressions).

serge_bg
+1  A: 

A by far easier way is to select an expression (here: baz.getBar()) and press CTRL+SHIFT+I (for inspect). This opens a tooltip like window with all you want to know.

Andreas_D
Indeed! Though, less flexible.
Matt Ball