...
Ideally, implement Serializable
only when the class is not expected to evolve frequently. One way to maintain the original serialized form , and at the same time allowing allow the class to evolve is to use custom serialization with the help of serialPersistentFields
. The static
and transient
fields allow one to specify what should not be serialized, whereas the serialPersistentFields
field specifies what should be serialized. It also relieves the class from defining the serializable field within the class implementation, decoupling the current implementation from the overall logic. New fields can easily be added without breaking compatibility across releases.
...
Related Guidelines
CWE ID -589 "Call to Non-ubiquitous API" |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b698a16e1daab955-d0cf8eb6-415a457e-bc839583-585150933fc3a3ba113385ce"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="09051cbfe99ed92c-b7db27b7-47684914-89379bbd-3261194f2809e430cd55ffe1"><ac:plain-text-body><![CDATA[ | [[Sun 2006 | AA. Bibliography#Sun 06]] | "Serialization specification", "1.5 Defining Serializable Fields for a Class" and "1.7 Accessing Serializable Fields of a Class" | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="778d7387f8c93275-a498e23f-410549c4-be6d9bf9-571f072e9c603bed89693b31"><ac:plain-text-body><![CDATA[ | [[Bloch 2008 | AA. Bibliography#Bloch 08]] | Item 74: "Implement serialization judiciously" | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="00e426ec02412a06-93a5b214-4da8449c-ba259605-29840e3efed35371056ed6a8"><ac:plain-text-body><![CDATA[ | [[Harold 2006 | AA. Bibliography#Harold 06]] | 13.7.5. serialPersistentFields | ]]></ac:plain-text-body></ac:structured-macro> |
...