JDK-8314581 : Add 'final' keyword to public property methods in controls
  • Type: CSR
  • Component: javafx
  • Sub-Component: controls
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: jfx22
  • Submitted: 2023-08-18
  • Updated: 2023-09-08
  • Resolved: 2023-09-08
Related Reports
CSR :  
Description
Summary
-------

Adding missing `final` keyword to the property accessor methods in the Control hierarchy.

Problem
-------

By design, accessor methods for properties in the Control hierarchy are declared `final`.  In some cases, the `final` keyword is missing, thus enabling the subclass to override behavior and break the behavior in unexpected ways.

Solution
--------

Add missing `final` keyword.

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

    javafx/scene/control/ChoiceBox.java
    -    public ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
    +    public final ObjectProperty<StringConverter<T>> converterProperty() { return converter; }

    -    public ObjectProperty<T> valueProperty() { return value; }
    +    public final ObjectProperty<T> valueProperty() { return value; }

    javafx/scene/control/ComboBox.java 
    -    public ObjectProperty<ObservableList<T>> itemsProperty() { return items; }
    +    public final ObjectProperty<ObservableList<T>> itemsProperty() { return items; }
 
    -    public ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
    +    public final ObjectProperty<StringConverter<T>> converterProperty() { return converter; }

    -    public ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty() { return cellFactory; }
    +    public final ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty() { return cellFactory; }
 
    -    public ObjectProperty<ListCell<T>> buttonCellProperty() { return buttonCell; }
    +    public final ObjectProperty<ListCell<T>> buttonCellProperty() { return buttonCell; }

    javafx/scene/control/ComboBoxBase.java
    -    public ObjectProperty<T> valueProperty() { return value; }
    +    public final ObjectProperty<T> valueProperty() { return value; }

     -    public BooleanProperty editableProperty() { return editable; }
    +    public final BooleanProperty editableProperty() { return editable; }

    -    public ReadOnlyBooleanProperty showingProperty() { return showingPropertyImpl().getReadOnlyProperty(); }
    +    public final ReadOnlyBooleanProperty showingProperty() { return showingPropertyImpl().getReadOnlyProperty(); }

    -    public BooleanProperty armedProperty() { return armed; }
    +    public final BooleanProperty armedProperty() { return armed; }

    javafx/scene/control/Label.java
    -    public ObjectProperty<Node> labelForProperty() {
    +    public final ObjectProperty<Node> labelForProperty() {

    scene/control/ListView.java
    -    public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
    +    public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {

    -    public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
    +    public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {

    -    public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
    +    public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {

    javafx/scene/control/TableView.java
    -    public void setOnSort(EventHandler<SortEvent<TableView<S>>> value) {
    +    public final void setOnSort(EventHandler<SortEvent<TableView<S>>> value) {

    -    public EventHandler<SortEvent<TableView<S>>> getOnSort() {
    +    public final EventHandler<SortEvent<TableView<S>>> getOnSort() {

    -    public ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSortProperty() {
    +    public final ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSortProperty() {

    -    public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
    +    public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {

    -    public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
    +    public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {

    -    public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
    +    public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {

    -    public void setOnScrollToColumn(EventHandler<ScrollToEvent<TableColumn<S, ?>>> value) {
    +    public final void setOnScrollToColumn(EventHandler<ScrollToEvent<TableColumn<S, ?>>> value) {

    -    public EventHandler<ScrollToEvent<TableColumn<S, ?>>> getOnScrollToColumn() {
    +    public final EventHandler<ScrollToEvent<TableColumn<S, ?>>> getOnScrollToColumn() {

    -    public ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumnProperty() {
    +    public final ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumnProperty() {

    javafx/scene/control/TreeTableView.java
    -    public void setOnSort(EventHandler<SortEvent<TreeTableView<S>>> value) {
    +    public final void setOnSort(EventHandler<SortEvent<TreeTableView<S>>> value) {

    -    public EventHandler<SortEvent<TreeTableView<S>>> getOnSort() {
    +    public final EventHandler<SortEvent<TreeTableView<S>>> getOnSort() {

    -    public ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSortProperty() {
    +    public final ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSortProperty() {

    -    public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
    +    public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {

    -    public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
    +    public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {

    -    public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
    +    public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {

    -    public void setOnScrollToColumn(EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> value) {
    +    public final void setOnScrollToColumn(EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> value) {

    -    public EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> getOnScrollToColumn() {
    +    public final EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> getOnScrollToColumn() {

    -    public ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumnProperty() {
    +    public final ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumnProperty() {



Comments
Moving to Approved, with comments. A change like this would nominally be out-of-policy for JDK or Java SE APIs, but FX has the option for different policies.
08-09-2023

thank you, finalized.
08-09-2023

Looks good. You can move this directly to Finalize.
08-09-2023

This looks good with following changes: 1. Change the risk to "low", since there is a known incompatibility (thus not "minimal") 2. This is also a binary incompatibility (in addition to a source incompatibility) 3. Can you remove the "private" fields from the Specification section (whether or not the private field is final is an implementation detail)
08-09-2023