Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8283811

Update ObjectStreamClass to be final

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 19
    • core-libs
    • None
    • source, binary
    • minimal
    • There should be no subclasses of ObjectStreamClass in any user code, so there should be no compatibility issues.
    • Java API
    • SE

      Summary

      Add the 'final' modifier to java.io.ObjectStreamClass.

      Problem

      ObjectStreamClass instances are created only from within the serialization mechanism, using either its private constructor or its package-private constructor. There are no subclasses of ObjectStreamClass.

      Solution

      ObjectStreamClass should be made final in order to express the design intent that it has no subclasses.

      Specification

      --- a/src/java.base/share/classes/java/io/ObjectStreamClass.java
      +++ b/src/java.base/share/classes/java/io/ObjectStreamClass.java
      @@ -80,7 +80,7 @@ import static java.io.ObjectStreamField.*;
        *      <cite>Java Object Serialization Specification,</cite> Section 4, "Class Descriptors"</a>
        * @since   1.1
        */
      -public class ObjectStreamClass implements Serializable {
      +public final class ObjectStreamClass implements Serializable {

            smarks Stuart Marks
            darcy Joe Darcy
            Daniel Fuchs, Jaikiran Pai, Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: