I need to compare two objects in Java, but they contain a lot of members, some not visible, and I don’t have access to the source code – they’re objects from a third-party package.
I need to find out what are the differences between them. Something like comparing chunks of memory in C++. But I don’t know how to do it in Java.
Any help?
EDIT: Some further info: I am doing some operations on two objects – on one the ops succeed, on the other they fail. However I can’t tell what’s different, that’s why I need this comparison. I can’t seem to get reflection to work, member not visible exception or smth like that on private members.
Take a look at this question Is there a Java reflection utility to do a deep comparison of two objects?
Unitils might help in your case