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

Add sealed modifier to java.awt.geom.Path2D

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 19
    • client-libs
    • None
    • 2d
    • source, binary
    • low
    • Hide
      If someone has circumvented package protections to subclass these, then they may no longer be able to do so. However the JDK now enforces strong encapsulation of JDK module internals, so this is not possible anyway without additional steps.

      The compatibility risk is both source and binary since as well as compile time checking of this, the VM enforces it at runtime.
      Show
      If someone has circumvented package protections to subclass these, then they may no longer be able to do so. However the JDK now enforces strong encapsulation of JDK module internals, so this is not possible anyway without additional steps. The compatibility risk is both source and binary since as well as compile time checking of this, the VM enforces it at runtime.
    • Java API
    • SE

      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

      - 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 
      

            prr Philip Race
            prr Philip Race
            Alexander Zuev, Brian Burkhalter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: