JDK-8284031 : Add sealed modifier to java.awt.geom.Path2D
  • Type: CSR
  • Component: client-libs
  • Sub-Component: 2d
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 19
  • Submitted: 2022-03-30
  • Updated: 2022-04-04
  • Resolved: 2022-04-04
Related Reports
CSR :  
Description
Summary
-------

Apply the sealed class modifer to java.awt.geom.Path2D

Problem
-------

java.awt.geom.Path2D allows only two direct sub-classes : Path2D.Float and Path2D.Double but this is not as clear as it could be.

Solution
--------

Use the new sealed class modifier to explicitly list the two allowed sub-classes.
This is safe since there are no public or protected constructors for Path2D.
However the sub-classes will need to be non-sealed since they do allow sub-classing. 

Specification
-------------

java.awt.geom.Path2D 

<pre>
- public abstract class Path2D implements Shape, Cloneable 
+ public abstract sealed class Path2D implements Shape, Cloneable
+     permits Path2D.Double,
+             Path2D.Float   

-     public static class Float extends Path2D implements Serializable 
+     public static non-sealed class Float extends Path2D implements Serializable 

-     public static class Double extends Path2D implements Serializable 
+     public static non-sealed class Double extends Path2D implements Serializable 
</pre>

Comments
Moving to Approved.
04-04-2022

Note that the serial classes here already define a serialVersionUID
30-03-2022