RFR: 8341372: BackgroundPosition, BorderImage, BorderStroke, CornerRadii should be final

Andy Goryachev angorya at openjdk.org
Wed Oct 2 14:55:42 UTC 2024


On Tue, 1 Oct 2024 21:46:21 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

> 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.

modules/javafx.graphics/src/main/java/javafx/scene/layout/BackgroundPosition.java line 55:

> 53:  * @since JavaFX 8.0
> 54:  */
> 55: public final class BackgroundPosition implements Interpolatable<BackgroundPosition> {

should we also declare the fields `final` as well?
horizontalSide, etc.

modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderImage.java line 53:

> 51:  * @since JavaFX 8.0
> 52:  */
> 53: public final class BorderImage implements Interpolatable<BorderImage> {

same question about final fields.

except for:
- innerEdge/outerEdge (used by border) and
- image use in Region:799 (could be accessed via getImage())

modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderStroke.java line 51:

> 49:  * @since JavaFX 8.0
> 50:  */
> 51: public final class BorderStroke implements Interpolatable<BorderStroke> {

same suggestion with final fields, except innerEdge/outerEdge

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1587#discussion_r1784677173
PR Review Comment: https://git.openjdk.org/jfx/pull/1587#discussion_r1784686671
PR Review Comment: https://git.openjdk.org/jfx/pull/1587#discussion_r1784689839


More information about the openjfx-dev mailing list