eclipse 使用java在eclipse中观察表达式不显示值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10671812/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:12:37  来源:igfitidea点击:

Watch expression doesnt show value in eclipse with java

javaeclipsedebuggingwatch

提问by Silvi

I am using eclipse helio with java.

我正在将 eclipse helio 与 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

谢谢

回答by Matt Zukowski

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.

就我而言,问题是我已将源查找路径指定为“文件系统目录”。通过删除“文件系统目录”路径并将源查找添加为“Java 项目”,我能够让我的表达式视图再次工作。

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:

您可以通过打开 Debug -> Display 视图并尝试在那里评估 Java 表达式来检查问题是否是您的源查找路径。如果您看到这样的消息,那么您的源查找路径是错误的:

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.

回答by AlexR

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.

通常刷新和清理项目 +(有时)重启 eclipse 帮助。

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.

如果你能看到简单的值而看不到表达式,有时是因为表达式返回的类没有出现在当前类的导入列表中。在这种情况下,我经常尝试将显式强制转换为类写入 watch 表达式,有时它会有所帮助。

Good luck.

祝你好运。

回答by 99Sono

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.

就我而言,在针对 Wildfly 进行调试时,在我将 eclipselink 2.6.4 的源代码作为 Maven 项目打开后,我的工作区不知何故遭到破坏。

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.

在打开这个 maven 项目后——它具有你可以在 oracle 库上想象的各种依赖项——在我的工作区中,表达式和显示视图根本不再起作用。变量视图,同时调试继续工作以及所有鼠标悬停。

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.

然后我创建了一个全新的空工作区。只导入我想调试的项目。重新配置的wildfly 服务器。瞧,表情和展示又恢复了工作。

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.

这似乎就是发生在我身上的事情。最后,我现在可以在这个新工作区中使用表达式了。