If this is just for debugging or if you want some form of basic serialization take a peek at XStream . Here is an example from their site talking about self references in particular...
Cd bj = new Cd("basement_jaxx_singles");
List order = new ArrayList();
// adds the same cd twice (two references to the same object)
order.add(bj);
order.add(bj);
// adds itself (cycle)
order.add(order);
XStream xstream = new XStream();
xstream.alias("cd", Cd.class);
System.out.println(xstream.toXML(order));
And the output is...
<list>
  <cd>
    <id>maria rita</id>
  </cd>
  <cd>
    <id>basement_jaxx_singles</id>
  </cd>
  <cd reference="../cd[2]"/>
  <list reference=".."/>
</list>