Details
-
Sub-task
-
Resolution: Delivered
-
P4
-
18
-
Verified
Description
The `java.io.ObjectInputStream.GetField.get(String name, Object val)` method now throws `ClassNotFoundException` when the class of the object is not found. Previously, null was returned, which prevented the caller from correctly handling the case where the class was not found. The signature of `GetField.get(name, val)` has been updated to throw `ClassNotFoundException`and a `ClassNotFoundException` exception is thrown when the class is not found.
The source compatibility risk is low. The addition of a throws `ClassNotFoundException` should not cause a source compatibility or a compilation warning. The `GetField` object and its methods are called within the context of the `readObject` method and include `throws ClassNotFoundException`.
To revert to the old behavior, a system property, `jdk.serialGetFieldCnfeReturnsNull`, has been added to the implementation. Setting the value to `true` reverts to the old behavior (returning null); leaving it unset or to any other value results in the throwing of `ClassNotFoundException`.
The source compatibility risk is low. The addition of a throws `ClassNotFoundException` should not cause a source compatibility or a compilation warning. The `GetField` object and its methods are called within the context of the `readObject` method and include `throws ClassNotFoundException`.
To revert to the old behavior, a system property, `jdk.serialGetFieldCnfeReturnsNull`, has been added to the implementation. Setting the value to `true` reverts to the old behavior (returning null); leaving it unset or to any other value results in the throwing of `ClassNotFoundException`.