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) now 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 so it prevented the caller from correctly handling the case where the class is not found. The signature of `GetField.get(name, val)` is 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 it includes `throws ClassNotFoundException`.

      To revert to the old behavior a system property `jdk.serialGetFieldCnfeReturnsNull` is 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

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

              Dates

              Created:
              Updated:
              Resolved: