Skip to content

Commit 3e10e78

Browse files
authored
Merge pull request #18480 from github/smowton/admin/document-serialization-proxy
Java: document serialization proxy pattern
2 parents 0ff37f1 + 0b62338 commit 3e10e78

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)