RFR: 8331224: ClassCastException in ObjectStreamClass during deserialization - cannot assign instance of java.util.CollSer to field of type java.util.Map
Roger Riggs
rriggs at openjdk.org
Wed May 1 18:50:02 UTC 2024
The issue reported a ClassCastException "cannot assign instance of java.util.CollSer to field of type java.util.Map"
while deserializing an object referring to an immutable Map that contained a reference to a class that was not available.
Immutable Collections such as Map utilize a serialization proxy in their serialized form.
During deserialization the serialization proxy (a private implementation class) was attempted to be set in a field resulting in the ClassCastException. The ClassCastException and bug hid the ClassCastException that should have been thrown.
When reading record fields or fields of a class, the results of deserialization of individual fields are recorded as dependencies of the object being constructed.
The apparent bug is that the summary of those dependencies is not checked between reading the fields and invoking the constructor to create the record or assigning the fields to an object being constructed.
-------------
Commit messages:
- 8331224: ClassCastException in ObjectStreamClass during deserialization
Changes: https://git.openjdk.org/jdk/pull/19043/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19043&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8331224
Stats: 192 lines in 2 files changed: 189 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/19043.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19043/head:pull/19043
PR: https://git.openjdk.org/jdk/pull/19043
More information about the core-libs-dev
mailing list