当Java对象的状态发生变化时,Eclipse调试器中是否有通知方式? [英] Is there a way in the Eclipse debugger to be notified when the state of a Java object changes?

查看:95
本文介绍了当Java对象的状态发生变化时,Eclipse调试器中是否有通知方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我知道它的对象标识符(调试时),那么我将调试一些旧代码,有没有办法看它,以便如果同一个线程或其他线程中的其他代码尝试修改其状态,它将触发我的调试?



我不能仅仅使用表达式手表,因为在其他地方可能会引用该对象,因为有许多同一个类的实例。

解决方案

在值更改时,在要停止的代码中设置断点。




  • 从断点视图开始。

  • 选择断点

  • 右键单击并转到断点属性

  • 检查启用条件框

  • 在文本字段中输入要观看的变量的名称

  • 选择条件更改值单选按钮


I'm debugging some legacy code where we have a cached object that appears to be changed externally.

If I know the object identifier for it (while debugging), is there some way to "watch" it so that if some other code in the same thread or another thread attempts to modify its state it'll trigger my debug?

I can't use just an expression watch for it since there may be references to that object elsewhere and as there are many instances of the same class.

解决方案

Set a breakpoint in the code you want to stop in when the value changes.

  • Start in the breakpoint view.
  • Select the breakpoint
  • right-click and goto the "breakpoint properties"
  • Check the 'Enable Condition' box
  • in the text field enter the name of the variable to watch
  • select the 'value of condition changes' radio button

这篇关于当Java对象的状态发生变化时,Eclipse调试器中是否有通知方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆