RFR: 8368172: Make java.time.format.DateTimePrintContext immutable

Shaojin Wen swen at openjdk.org
Sat Sep 20 00:39:38 UTC 2025


I propose to make j.t.f.DateTimePrintContext immutable.

Currently, DateTimePrintContext has only one mutable field, optional. This can be replaced by adding an optional parameter to the DateTimeFormatter.formatTo method.

Immutable DateTimePrintContext can be optimized by escape analysis, such as immutable object optimization.

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

Commit messages:
 - fix javadoc & copyright
 - Apply suggestion from @liach
 - add javadoc
 - add javadoc
 - stable DateTimePrintContext

Changes: https://git.openjdk.org/jdk/pull/26913/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26913&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8368172
  Stats: 84 lines in 3 files changed: 5 ins; 32 del; 47 mod
  Patch: https://git.openjdk.org/jdk/pull/26913.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26913/head:pull/26913

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


More information about the core-libs-dev mailing list