SyncMaster
SyncMaster

Reputation: 9946

Copy entire tree of an object in Eclipse Debug mode

When I am on Eclipse debug mode, I would like to copy the entire tree of an object. Is there an easy way to do it?

The object has several structures and hashmaps nested inside it. So expanding every entry is tedious process.

I would like to copy the entire object and then later inspect it. How can I do it? Thanks!

Upvotes: 3

Views: 1608

Answers (1)

elonderin
elonderin

Reputation: 537

you could serialize the object graph to a file -- if all of the connected obejcts are serializable.

I have done this myself by writing a TestUtils.serialize(Serializable, String) method. i have used internally apache's SerializationUtils and where the string is a file path.

use this when execution has stopped on a breakpoint:

  1. open the display view
  2. call the serialize() method with the appropriate args

later you can deserialze the file to the object graph again (e.g. in a unit test ) and then inspect it or extract portions of it or whatever.

if not all objects are serializable you need to beef up your serialize() to handle these cases or use some other generic serialization library that can handle such stuff.

other alternatives are, but probably insufficient for your problem:

  • write a custom to string() for the debug/expression view that only contains the really needed values
  • use a screenshot tool like greenshot

Upvotes: 1

Related Questions