Reputation: 9946
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
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:
serialize()
method with the appropriate argslater 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:
string()
for the debug/expression view that only contains the really needed valuesUpvotes: 1