Skip to content

Commit 0b62338

Browse files
authored
Java: document serialization proxy pattern
Note I haven't included a reference because I can't find a sufficiently-authoritative source -- only a blog quoting Effective Java seems close to appropriate, and I suspect that's pirated.
1 parent fcf6c3c commit 0b62338

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

java/ql/src/Likely Bugs/Serialization/MissingVoidConstructorsOnSerializable.qhelp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ is not the case. The error will be detected at runtime. </p>
2323

2424
</overview>
2525
<recommendation>
26-
<p>Make sure that every non-serializable class that is extended by a serializable class has a no-argument constructor.</p>
26+
<p>Make sure that every non-serializable class that is extended by a serializable class has a no-argument constructor.
27+
Alternatively, consider defining a <code>writeReplace</code> method that replaces the <code>Serializable</code> class instance with
28+
a serialization proxy, so as to avoid direct deserialization of a class whose parent lacks a no-argument constructor.</p>
2729

2830
</recommendation>
2931
<example>

0 commit comments

Comments
 (0)