在 Eclipse 中调试时修改/查看静态变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/801193/
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
Modify/view static variables while debugging in Eclipse
提问by mcccclean
As per the question. In the debug view, there's the Variables frame. It shows all the values of member variables of the current object, and all of the local variables, but it doesn't show any static variables of the object's class.
根据问题。在调试视图中,有变量框架。它显示了当前对象的所有成员变量的值,以及所有的局部变量,但不显示该对象类的任何静态变量。
How do I get to these?
我如何获得这些?
Some googling has suggested I press the button on the toolbar, but there's nothing on the Variables frame's toolbar except "Show Type Names" "Logical Structure" and "Collapse All" (Eclipse 3.4.2).
一些谷歌搜索建议我按下工具栏上的按钮,但除了“显示类型名称”、“逻辑结构”和“全部折叠”(Eclipse 3.4.2)之外,变量框架的工具栏上没有任何内容。
Any advice?
有什么建议吗?
回答by Markus Lausberg
In the Debug Variables view their is a arrow button in the right of the view. the tooltip of this button is Menu
.
在调试变量视图中,它们是视图右侧的箭头按钮。此按钮的工具提示是Menu
。
When you click this button a drop down menu is shown where you can select
当您单击此按钮时,会显示一个下拉菜单,您可以在其中选择
Java
-> Show static variables
Java
-> Show static variables
Note: You do not have to restart Eclipse.
注意:您不必重新启动 Eclipse。
回答by Bhushan Bhangale
Simply put your mouse cursor over the static variable in the code and you will see the assigned value.
只需将鼠标光标放在代码中的静态变量上,您就会看到分配的值。
回答by zishan paya
回答by zishan paya
Window
-> Show View
-> Other
-> Debug
-> Expressions
-> Right Click on Window -> Add Watch Expression...
-> Enter the name of the variable you want to see
Window
-> -> Show View
-> Other
-> Debug
-> Expressions
-> 右击窗口 -> Add Watch Expression...
-> 输入你想查看的变量名
回答by codeDisaster
You might also try writing the expression e.g. self::$value in the watch window
您也可以尝试在监视窗口中编写表达式,例如 self::$value