11

The variable view of the Eclipse Java Debug mode allows to inspect the values of variables. What I'm frequently missing is to inspect the return value of methods: if such a return value is not stored into a variable but immediately used to call one of its methods, it is not visible in the debugger.

For example, consider foo.getBar().equals("xxx"); where getBar() yields a String. If the source of foo is unavailable, how can the result of getBar() be inspected before the call to .equals()? Of course, one can change the code by introducing a local variable that holds the result. But that is too unpractical in general.

Eclipse Standard/SDK

Version: Luna Service Release 1 (4.4.1) Build id: 20140925-1800

Ulrich Scholz
  • 2,039
  • 4
  • 30
  • 51
  • You dont need the source. Jump into the method and your value is presented in the variables view without seeing the source. – Grim Nov 10 '14 at 14:30

1 Answers1

14

You can select the expression to inspect (in this case select foo.getBar()), then right-click and select "Inspect", or type the shortcut Ctrl+Shift+i. The side effect is that it will execute the method, so changes done in the method on, say, member fields will be applied.

See Evaluating expressions in a debugging session, transferred from SO Documentation, as a related documentation example.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
M A
  • 71,713
  • 13
  • 134
  • 174