title: Is there a Java library that can "diff" two Objects?
body: <p>Is there a Java utility library that is analogous to the Unix program diff, but for Objects?  I'm looking for something that can compare two objects of the same type and generate a data structure that represents the differences between them (and can recursively compare differences in instance variables).  I'm <strong>not</strong> looking for a Java implementation of a text diff.  I'm also <strong>not</strong> looking for help with  how to use reflection to do this.</p>
  
  <p>The application I'm maintaining has a fragile implementation of this functionality that had some poor design choices and that needs to be rewritten, but it would be even better if we could use something off the shelf.</p>
  
  <p>Here's an example of the kind of thing I'm looking for:</p>
  
  <pre><code>SomeClass a = new SomeClass();
  SomeClass b = new SomeClass();
  
  a.setProp1("A");
  a.setProp2("X");
  
  b.setProp1("B");
  b.setProp2("X");
  
  DiffDataStructure diff = OffTheShelfUtility.diff(a, b);  // magical recursive comparison happens here
  </code></pre>
  
  <p>After comparison, the utility would tell me that "prop1" is different between the two objects and "prop2" is the same.  I think it's most natural for DiffDataStructure to be a tree, but I'm not going to be picky if the code is reliable.</p>