JDK-8283811 : Update ObjectStreamClass to be final
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P4
  • Status: Draft
  • Resolution: Unresolved
  • Fix Versions: tbd
  • Submitted: 2022-03-29
  • Updated: 2022-03-29
Related Reports
CSR :  
Description
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 {