Requirement: I need to dump the object graph of a Java application at various points of time during the application's execution. But most importantly, the dump needs to contain metadata for all objects in the graph e.g. the reference ids as obtained from System.identityHashCode(object)
.
What I tried: I found out serialization is a goto solution for obtaining the object graph.
I tried a couple of different solutions, including the built in Serialization facility in Java, JAXB and XStream. But I have no clue on how to get any of these libraries to spit out the objects' metadata such as the original reference IDs for the objects getting serialized.
Question: I was wondering if there was an easy way to include additional information/metadata about each object in an object graph that gets serialized?
While i am interested in specifically storing the objects' reference id, as obtained by System.identityHashCode()
, any pointers on storing any data in general will be acceptable.
In case adding such metadata is not possible, that information will be useful as well.
NOTE: I ask this question despite the knowledge that the reference ids obtained from the System.identityHashCode()
method are not required to be unique across different objects.
P.S. I am a newbie with Java serialization.