JDK-8320615 : Deprecate for removal protected access methods in converters
  • Type: CSR
  • Component: javafx
  • Sub-Component: base
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: jfx22
  • Submitted: 2023-11-22
  • Updated: 2023-12-04
  • Resolved: 2023-12-04
Related Reports
CSR :  
Relates :  
Description
Summary
-------

`TimeStringConverter` and `DateStringConverter` expose `getDateFormat()` by mistake after it was removed already in `DateTimeStringConverter`.
`NumberStringConverter` (and subclasses) expose `getNumberFormat()` by mistake as well.

Problem
-------

The above protected methods allow access to internal states. These should not be part of the public API.

Solution
--------

Deprecate for removal the protected access methods so that they can be removed from public API.

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

    diff --git a/modules/javafx.base/src/main/java/javafx/util/converter/CurrencyStringConverter.java b/modules/javafx.base/src/main/java/javafx/util/converter/CurrencyStringConverter.java
    index c8340a6fb16..65cd2bbd532 100644
    --- a/modules/javafx.base/src/main/java/javafx/util/converter/CurrencyStringConverter.java
    +++ b/modules/javafx.base/src/main/java/javafx/util/converter/CurrencyStringConverter.java
    @@ -89,8 +89,12 @@ public CurrencyStringConverter(NumberFormat numberFormat) {
             super(null, null, numberFormat);
         }
     
    -    /** {@inheritDoc} */
    -    @Override protected NumberFormat getNumberFormat() {
    +    /**
    +    * @deprecated This method was exposed erroneously and will be removed in a future version.
    +    */
    +    @Deprecated(forRemoval = true, since = "22")
    +    @Override
    +    protected NumberFormat getNumberFormat() {
             Locale _locale = locale == null ? Locale.getDefault() : locale;
     
             if (numberFormat != null) {
    diff --git a/modules/javafx.base/src/main/java/javafx/util/converter/DateStringConverter.java b/modules/javafx.base/src/main/java/javafx/util/converter/DateStringConverter.java
    index 2b70b3427b3..232b72cbc9e 100644
    --- a/modules/javafx.base/src/main/java/javafx/util/converter/DateStringConverter.java
    +++ b/modules/javafx.base/src/main/java/javafx/util/converter/DateStringConverter.java
    @@ -126,8 +126,12 @@ private DateStringConverter(Locale locale, String pattern, DateFormat dateFormat
     
         // --------------------------------------------------------- Private Methods
     
    -    /** {@inheritDoc} */
    -    @Override protected DateFormat getDateFormat() {
    +    /**
    +     * @deprecated This method was exposed erroneously and will be removed in a future version.
    +     */
    +    @Deprecated(forRemoval = true, since = "22")
    +    @Override
    +    protected DateFormat getDateFormat() {
             DateFormat df = null;
     
             if (dateFormat != null) {
    diff --git a/modules/javafx.base/src/main/java/javafx/util/converter/DateTimeStringConverter.java b/modules/javafx.base/src/main/java/javafx/util/converter/DateTimeStringConverter.java
    index 3983b9b71c4..0ab26ea41a1 100644
    --- a/modules/javafx.base/src/main/java/javafx/util/converter/DateTimeStringConverter.java
    +++ b/modules/javafx.base/src/main/java/javafx/util/converter/DateTimeStringConverter.java
    @@ -191,7 +191,7 @@ public DateTimeStringConverter(DateFormat dateFormat) {
         // --------------------------------------------------------- Private Methods
     
         /**
    -     * <p>Return a <code>DateFormat</code> instance to use for formatting
    +     * <p>Returns a <code>DateFormat</code> instance to use for formatting
          * and parsing in this {@link StringConverter}.</p>
          *
          * @return a {@code DateFormat} instance for formatting and parsing in this
    diff --git a/modules/javafx.base/src/main/java/javafx/util/converter/NumberStringConverter.java b/modules/javafx.base/src/main/java/javafx/util/converter/NumberStringConverter.java
    index b9a4bfacef4..f9eefc0cddb 100644
    --- a/modules/javafx.base/src/main/java/javafx/util/converter/NumberStringConverter.java
    +++ b/modules/javafx.base/src/main/java/javafx/util/converter/NumberStringConverter.java
    @@ -141,7 +141,9 @@ public NumberStringConverter(NumberFormat numberFormat) {
          *
          * @return a {@code NumberFormat} instance for formatting and parsing in this
          * {@code StringConverter}
    +     * @deprecated This method was exposed erroneously and will be removed in a future version.
          */
    +    @Deprecated(forRemoval = true, since = "22")
         protected NumberFormat getNumberFormat() {
             Locale _locale = locale == null ? Locale.getDefault() : locale;
     
    diff --git a/modules/javafx.base/src/main/java/javafx/util/converter/PercentageStringConverter.java b/modules/javafx.base/src/main/java/javafx/util/converter/PercentageStringConverter.java
    index f393ac55353..1e7f706c08f 100644
    --- a/modules/javafx.base/src/main/java/javafx/util/converter/PercentageStringConverter.java
    +++ b/modules/javafx.base/src/main/java/javafx/util/converter/PercentageStringConverter.java
    @@ -65,8 +65,12 @@ public PercentageStringConverter(NumberFormat numberFormat) {
             super(null, null, numberFormat);
         }
     
    -    /** {@inheritDoc} */
    -    @Override public NumberFormat getNumberFormat() {
    +    /**
    +     * @deprecated This method was exposed erroneously and will be removed in a future version.
    +     */
    +    @Deprecated(forRemoval = true, since = "22")
    +    @Override
    +    public NumberFormat getNumberFormat() {
             Locale _locale = locale == null ? Locale.getDefault() : locale;
     
             if (numberFormat != null) {
    diff --git a/modules/javafx.base/src/main/java/javafx/util/converter/TimeStringConverter.java b/modules/javafx.base/src/main/java/javafx/util/converter/TimeStringConverter.java
    index 3d5d923d7d0..ff19e3a8018 100644
    --- a/modules/javafx.base/src/main/java/javafx/util/converter/TimeStringConverter.java
    +++ b/modules/javafx.base/src/main/java/javafx/util/converter/TimeStringConverter.java
    @@ -127,8 +127,12 @@ private TimeStringConverter(Locale locale, String pattern, DateFormat dateFormat
     
         // --------------------------------------------------------- Private Methods
     
    -    /** {@inheritDoc} */
    -    @Override protected DateFormat getDateFormat() {
    +    /**
    +     * @deprecated This method was exposed erroneously and will be removed in a future version.
    +     */
    +    @Deprecated(forRemoval = true, since = "22")
    +    @Override
    +    protected DateFormat getDateFormat() {
             DateFormat df = null;
     
             if (dateFormat != null) {
Comments
Moving to Approved.
04-12-2023

[~nlisker] This looks good and is ready for you to "Finalize".
01-12-2023

> FYI, sometimes in the JDK as part of deprecating for removal as an additional step before removing we'll make the methods in question unconditionally throw an exception. Thanks for the suggestion, that seems like a good idea for cases where the API might reasonably be in use. In this case, given how unlikely it is that any application has ever overridden these classes, much less overridden or called the methods in question, we'll plan to do what we did for the similar methods in the base classes: remove them from the public API in one go by making them package scope (thus hiding them). This will cause an IllegalAccessError anyway if the application were to run an existing binary and call the methods after we make them package scope.
01-12-2023

Moving to Provisional. FYI, sometimes in the JDK as part of deprecating for removal as an additional step before removing we'll make the methods in question unconditionally throw an exception.
27-11-2023