Reputation: 821
Is there any way to check the value of a particular expression when debugging with eclipse? The expression view isn't always that useful.
For example:
public class P
{
public boolean executed = false;
public String getSomeString() {
if (!executed) {
executed = true; //set executed to true,so calling this method again will not yield the same result
return "someStr";
}else {
throw new RuntimeException();
}
}
}
Here is main method:
public class Test {
public static void main(String[] args) {
P p = new P();
p.getSomeString(); //breakpoint here, I want to check the value of this expression, but it is not assign to a variable.
System.out.println();
}
}
I came up with this problem when I was debugging Struts2.
in the body of Dispatcher#serviceAction()
, there is a line proxy.execute();
which is a String value that comes from DefaultActionInvocation#invoke()
, basically the returned String from Actions.
But the value of proxy.execute();
is not assigned to a variable or used anywhere inside Dispatcher#serviceAction()
. So how is returned String from actions associated with the views?
Upvotes: 3
Views: 5516
Reputation: 6248
You can check any variable value by mouse over, or just press CTRL+SHIFT+I after selecting any expression.
OR
You can add variable in watch expression of debug mode.
Upvotes: 2
Reputation: 344
Just mark the expression an press Ctrl+Shift+I or "Run"/"Inspect" from the navigation. Or you can use the "Display" view. Here you can write and store the expression, you want to check.
Upvotes: 5