15
votes

I am using eclipse helio with java.

The watch expression option is not working for me when debugging my code

If I am doing a watch on variable, I cant see the value of that variable in the watch view if i hoover with my mouse over the variable in the code i can see its value if I check the variable in the variables view I can see its value

but in the watch expressions window i cant see its value (and its a problem if i try to watch expressions for example)

did anyone encounter this problem

(it used to work fine and show values but then suddenly it stopped and i have no idea why)

thanks

3
For me, the issue seems to be related to this bug in Eclipse: bugs.eclipse.org/bugs/show_bug.cgi?id=564801 Fortunately, it only seems to happen when stepping through code within the body of a lambda expression. - matt forsythe

3 Answers

14
votes

For me the problem had to do with a bad source path configuration for the project. There's a bunch of different ways to fix this, but one is to right-click on the thread while paused in the debugger, select "Edit Source Lookup...", and fiddle around with the paths specified there (see below).

enter image description here

In my case the problem was that I had specified the source lookup path as a "File System Directory". I was able to get my Expressions view working again by removing the "File System Directory" path and adding the source lookup as a "Java Project" instead.

You can check whether the problem is your source lookup path by opening the Debug -> Display view, and trying to evaluate a Java expression there. If you see a message like this, then your source lookup path is bad:

To perform an evaluation, an expression must be compiled in the context of a Java project's build path. The current execution context is not associated with a Java project in the workspace.
4
votes

Typically (at least for simple cases) the expression view works. But sometimes it indeed stops showing the values.

Usually refresh and clean of project + (sometimes) restart of eclipse help.

If you are able to see simple values and cannot see expression it sometimes because the class that is returned by expression does not appear in import list of current class. In this case I often try to write explicit cast to class into the watch expression and sometimes it helps.

Good luck.

0
votes

In my case, while debugging against wildfly, my workspace somehow got corrupted after I opened as a maven project the sources of eclipselink 2.6.4.

After having open this maven project - that has all sort of dependencies you can image on oracle libraries - within my workspace the expressions and display view simply did not work any more. The variables view, while debugging continue to work as well as all the mouse overs.

I then created a fresh new empty worksapace. Imported only the project I wanted to debug. Reconfigured wildfly server. And voila, expressions and display were back to work.

So, I have no idea what what happened to my eclipse... but it appears to be related to the metadata in my workspace being fundamentally broken.

Therefore, if you get the feeling that out of the blue lose the ability to properly debug in your workspace, it might be that your worksapce got hammered.

This appears to be what has happened to me. Finally, I am now back to being able to use the expressions on this new workspace.