Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
serialVersionUID denotes the version number of a serialized Java class. All serialized Java classes with the same serial Version UID and name are considered to be compatible, even if the actual Java classes from which they originated are different.
This can easily happen when you serialize one version of a class, change its structure (add a field, for example), then serialize some more instances. Without a serial Version UID field, Java would refuse to load the older version into the newer class with the additional field. With the serial Version UID field, Java will still load the older version into the new class, but will set the value of the new field to 0, null, or false, as appropriate to its data type.
[Java ist auch eine Insel hat gesagt.:]Bei der Serialisierung wird in Java nicht nur der Objektinhalt geschrieben, sondern zusätzlich noch eine eindeutige Kennung der Klasse, die UID. Die UID ist ein Hashcode aus Namen, Attributen, Parametern, Sichtbarkeit und so weiter. Sie wird als long wie ein Attribut gespeichert. Ändert sich der Aufbau einer Klasse, ändert sich der Hashcode und damit die UID. Klassen mit unterschiedlicher UID sind nicht kompatibel. Erkennt der Lesemechanismus in einem Datenstrom eine UID, die nicht zu der Klasse passt, wird eine InvalidClassException ausgelöst. Das bedeutet, dass schon ein einfaches Zufügen von Attributen zu einem Fehler führt.