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

BackgroundPosition, BorderImage, BorderStroke, CornerRadii should be final

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • jfx24
    • javafx
    • None
    • source, binary
    • low
    • This is a breaking change for applications that subclass one of the affected classes. However, subclassing is not an intended usage for these classes and is very unlikely to be done in practice.
    • Java API
    • JDK

      Summary

      The final modifier will be added to the BackgroundPosition, BorderImage, BorderStroke, and CornerRadii classes.

      Problem

      Backgrounds and borders are comprised of immutable and final types. The following types are marked with the final modifier:

      • Background
      • BackgroundFill
      • BackgroundImage
      • BackgroundSize
      • Border
      • BorderWidths

      The following types are not marked with the final modifier:

      • BackgroundPosition
      • BorderImage
      • BorderStroke
      • CornerRadii

      This is probably just an oversight, as there is no value in allowing a subsection of these types to be extended.

      Solution

      Add the final modifier.

      Specification

      --- a/modules/javafx.graphics/src/main/java/javafx/scene/layout/BackgroundPosition.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/scene/layout/BackgroundPosition.java
      @@ -52,7 +52,7 @@
        * the Region's right edge.
        * @since JavaFX 8.0
        */
      -public class BackgroundPosition implements Interpolatable<BackgroundPosition> {
      +public final class BackgroundPosition implements Interpolatable<BackgroundPosition> {
           /**
            * The default BackgroundPosition for any BackgroundImage. The default
            * is to have no insets and to be defined as 0% and 0%. That is, the
      --- a/modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderImage.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderImage.java
      @@ -50,7 +50,7 @@
        * When applied to a Region with a defined shape, a BorderImage is ignored.
        * @since JavaFX 8.0
        */
      -public class BorderImage implements Interpolatable<BorderImage> {
      +public final class BorderImage implements Interpolatable<BorderImage> {
           /**
            * The image to be used. This will never be null. If this
            * image fails to load, then the entire BorderImage will
      --- a/modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderStroke.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderStroke.java
      @@ -48,7 +48,7 @@
        *
        * @since JavaFX 8.0
        */
      -public class BorderStroke implements Interpolatable<BorderStroke> {
      +public final class BorderStroke implements Interpolatable<BorderStroke> {
           /**
            * The default insets when "thin" is specified.
            */
      --- a/modules/javafx.graphics/src/main/java/javafx/scene/layout/CornerRadii.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/scene/layout/CornerRadii.java
      @@ -39,7 +39,7 @@
        *
        * @since JavaFX 8.0
        */
      -public class CornerRadii implements Interpolatable<CornerRadii> {
      +public final class CornerRadii implements Interpolatable<CornerRadii> {
           /**
            * A CornerRadii which is entirely empty, indicating squared corners.
            * This is the default value for a BorderStroke's radii.

            mstrauss Michael Strauß
            mstrauss Michael Strauß
            Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: