I\'m looking for a solution to generate a checksum for any type of Java object, which remains the same for every execution of an application that produces the same object.>
The Apache commons lang library provides a HashCodeBuilder
class which helps building a hash code that fills your requirements from the class properties.
Example:
public int checksum() {
// you pick a hard-coded, randomly chosen, non-zero, odd number
// ideally different for each class
return new HashCodeBuilder(17, 37).
append(property1).
append(property2).
append(property3).
toHashCode();
}
See Commons Lang API