简体   繁体   English

Eclipse在调试期间自行更改变量

[英]Eclipse changes variable on its own during debugging

I've come across what seems to be a bug in Eclipse Kepler while debugging. 我在调试时遇到了Eclipse Kepler中似乎是一个错误的错误。 One of my variables is incrementing itself randomly with every step of the debugger, even through steps that do not change the variable at all. 我的变量之一是在调试器的每个步骤中随机递增自己,即使是完全不更改变量的步骤。 Screenshots included below: 屏幕截图如下:

在此处输入图片说明

The method advanceLine() increments progress by one 方法advanceLine() progress递增一

在此处输入图片说明

The very next step, progress increments twice, before it even reaches the increment 下一步, progress递增两次,甚至达到增量之前

There is another thread that accesses progress , but it does not modify it. 还有另一个线程可以访问progress ,但不会对其进行修改。 These random changes don't seem to affect my program at all, just the debug view. 这些随机更改似乎根本不会影响我的程序,而只会影响调试视图。 Also, for some reason, the shortcut to Step-Into (F5) doesn't work despite being already bound. 同样,由于某种原因,尽管已绑定到Step-Into(F5)的快捷方式也无法使用。 Does anybody know what's going on? 有人知道发生了什么吗?

Variable progress is a class variable and if it is getting updated ambiguosly, it is possible that another thread is modifying your variable. 变量进度是一个类变量,如果对其进行不明确的更新,则可能是另一个线程正在修改您的变量。 Please make your variable local. 请将您的变量设为本地。 There is no way eclipse interferes your coding logic unless you explicitly right click on a variable and change its value. 除非您明确右键单击变量并更改其值,否则蚀不会干扰您的编码逻辑。

Well.. I figured it out. 好吧..我知道了。 I removed the variable watch from the Expressions view and added it back in. Lo and behold, it displays normally and my code has not altered at all. 我从“表达式”视图中删除了变量watch,然后又将其添加回去。瞧瞧,它正常显示,并且我的代码完全没有改变。 I think it was just the view that was acting wonky because like @Vineet says, Eclipse does not modify values in your code unless you tell it to. 我认为这只是一种奇怪的观点,因为就像@Vineet所说的那样,除非您告知Eclipse,否则Eclipse不会修改代码中的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM