<i18n dev> RFR: 8313205: Modernize java.text.Format with StringBuilder

Justin Lu jlu at openjdk.org
Thu Jul 25 22:23:45 UTC 2024


Please review this PR which adds public StringBuilder overloads to the formatting methods of java.text.Format and implementing subclasses.

While Format, NumberFormat, and DateFormat are abstract, these new methods are not added as abstract to prevent compatibility concerns. Instead they are added as non-abstract methods, with a default implementation that throws UOE and a recommendation that subclasses override and provide their own implementations. These new methods use the same specification as the StringBuffer ones, with exception of `MessageFormat.format(format(Object[] arguments, StringBuilder result, FieldPosition pos)` which omits the table, and instead links to it.

The JDK implementing Format classes, (such as DecimalFormat) leverage the StringBuf proxy methods.

A corresponding CSR has been drafted: https://bugs.openjdk.org/browse/JDK-8337141, which goes into detail on motivation/history. (Holding off on uploading the specification to CSR until wording finalized).

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

Commit messages:
 - init

Changes: https://git.openjdk.org/jdk/pull/20337/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20337&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8313205
  Stats: 883 lines in 12 files changed: 881 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/20337.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20337/head:pull/20337

PR: https://git.openjdk.org/jdk/pull/20337


More information about the i18n-dev mailing list