Search code examples
javaserializationfile-io

error: local class incompatible: stream classdec serialversionUID= ...., local class serialversionUID=


I have a serializable java class and when I add either of the following methods. I get this error

" local class incompatible: stream classdec serialversionUID= ...., local class serialversionUID=..."

added methods:

public HashMap<Long, BookIndex> getBookIndexMap() {
    return bookIndexMap;
}

public String getDataFileName() {
    return dataFileName;
}

what is causing this and how can I correct it?


Solution

  • This article may be helpful, by changing the class's method signatures, previous serialized forms are incompatible unless the classes have the same serialVersionUID.