java.io.InvalidClassException: local class incompatible:

前端 未结 7 1849
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 02:46

I created client and server and then added a class in client side for serializing purposes, then simply just went to the folder of the client in my hard drive and copy paste

7条回答
  •  Happy的楠姐
    2020-11-29 03:26

    One thing that could have happened:

    • 1: you create your serialized data with a given library A (version X)
    • 2: you then try to read this data with the same library A (but version Y)

    Hence, at compile time for the version X, the JVM will generate a first Serial ID (for version X) and it will do the same with the other version Y (another Serial ID).

    When your program tries to de-serialize the data, it can't because the two classes do not have the same Serial ID and your program have no guarantee that the two Serialized objects correspond to the same class format.

    Assuming you changed your constructor in the mean time and this should make sense to you.

提交回复
热议问题