RFR: 8273660: Propagate CNF exception in FieldValues.get via an IOException
Roger Riggs
rriggs at openjdk.java.net
Wed Oct 20 22:05:18 UTC 2021
The ObjectInputStream.GetField method `get(String name, Object val)` should have been throwing
a ClassNotFoundException if the class was not found. Instead the implementation was returning null.
A design error does not allow the `get(String name, Object val)` method to throw CNFE as it should.
However, an exception must be thrown to prevent invalid data from being returned.
Wrapping the CNFE in IOException allows it to be thrown and the exception handled.
The call to `get(String name, Object val)` is always from within a `readObject` method
so the deserialization logic can catch the IOException and unwrap it to handle the CNFE.
-------------
Commit messages:
- 8273660: Propagate CNF exception in FieldValues.get via an IOException
Changes: https://git.openjdk.java.net/jdk/pull/6053/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6053&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8273660
Stats: 112 lines in 2 files changed: 109 ins; 0 del; 3 mod
Patch: https://git.openjdk.java.net/jdk/pull/6053.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6053/head:pull/6053
PR: https://git.openjdk.java.net/jdk/pull/6053
More information about the core-libs-dev
mailing list