Search code examples
javaeclipsedebuggingobjectbreakpoints

How to see all changes in complex variable using Eclipse Juno


I have a complex object, with 30 or so fields, which themselves contain objects which have lots of fields.

What I really want to do is this; when at a breakpoint, ctrl-c to copy the entire structure as I see it in the variables (or expressions) window. Then run some code, then ctrl-c the entire structure again, and then compare them side-by-side.

However, Eclipse (Juno) doesn't allow me to copy the entire structure. And even if I expand all of the objects inside my object when stepping through code, it does not highlight the changes made to each and every field from one line to the next.

I would also be okay with somehow creating some kind of breakpoint trigger when the object is modified, but it's an external jar file doing the modifying, so I'm not sure how that would work, nor do I think Eclipse would bother to show me the data that changed if it even is possible. (If it is, it's not at all intuitive).

Any help would be much appreciated.

Charles.


Solution

  • Write yourself a detail formatter for the object you want to inspect. You can imagine that to be something like an "externalized toString() method". It even gives you access to private members of the inspected object. You can then feed this output into your preferred diff tool.