Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8276665 ObjectInputStream.GetField.get(name, object) should throw ClassNotFoundException
  3. JDK-8277135

Release Note: ObjectInputStream.GetField.get(name, object) Throws ClassNotFoundException

    XMLWordPrintable

Details

    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`.

      Attachments

        Activity

          People

            rriggs Roger Riggs
            rriggs Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: