I have a class while serialization
public class Name implements Serializable {
private final String firstName;
private final String lastName;
public Name(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
}
But while de-serializing I have an extra method(mentioned below) that is not affecting object state in any way and serialization is all about storing the object state then why an extra method is having contribution in the hash generation for serialversionuid. In current scenario it will fail with InvalidClassException. But object state is not getting changed by this extra method.
public String getFullName() {
return firstName + " " + lastName;
}