Monday, 15 June 2015

java - ClassCastException with newer version of the class -



java - ClassCastException with newer version of the class -

i have reached stage new version of class needs defined. new class definition methods have been added, info members type has changed. question is, how go on serve older clients, while ensuring server unchanged.

exception

java.io.invalidclassexception: com.mcruiseon.carpool.concrete.subscribejourneyconcrete; incompatible types field isjourneyactive

with new class, there no isjourneyactive.

i know missing basic here, checking serialversionuid.

one suggestion is, whenever method doesn't exist anymore, deprecate it.

one way of going having intermediate version method deprecated.

so on version 1 method isjourneyactive beingness used on version 2 method isjourneyactive still beingness used, want clients start using method setjourneyactive instead, deprecated isjourneyactive on version 3 method isjourneyactive no longer there, or nowadays throw exception when user tries utilize it.

there other ways, more complex deprecating methods.

java serialization

No comments:

Post a Comment