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

ChoiceFormat should advise throwing UnsupportedOperationException for unused methods

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P5 P5
    • 23
    • core-libs
    • None
    • behavioral
    • minimal
    • Specification update only, minimal risk.
    • Java API
    • SE

      Summary

      Update the java.text.ChoiceFormat class description to recommend throwing UnsupportedOperationException for unused inherited methods.

      Problem

      java.text.ChoiceFormat inherits many methods from java.text.NumberFormat that it does not use. While it would have been ideal that

      1) ChoiceFormat did not extend NumberFormat in the first place to not have these unused methods

      2) ChoiceFormat throws UnsupportedOperationException for such methods

      Both solutions should not be done due to compatibility concerns. However, the problem still persists that these methods are inherited, but unused.

      Solution

      In the class description, recommend via the existing apiNote tag that subclasses of ChoiceFormat themselves throw a UnsupportedOperationException for these unused methods. This wording is kept general/broad, as listing every method in question while precise, would simply add unneeded noise and take away from the other text in the class description.

      Specification

      In the class description, add to the apiNote tag,

        * @apiNote A subclass could perform more consistent pattern validation by
        * throwing an {@code IllegalArgumentException} for all incorrect cases.
      + * <p>This class inherits instance methods from {@code NumberFormat} it does
      + * not utilize; a subclass could override and throw {@code
      + * UnsupportedOperationException} for such methods.

            jlu Justin Lu
            jlu Justin Lu
            Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: