RFR: 8368172: Make java.time.format.DateTimePrintContext immutable [v4]

Roger Riggs rriggs at openjdk.org
Fri Sep 26 15:17:07 UTC 2025


On Fri, 26 Sep 2025 04:04:40 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> 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.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   add DateTimePrinterParser#withOptional, from @RogerRiggs

This has a much more invasive impact on PrinterParsers than the version with an extra argument on the format method.
Are there other implementations of the nested depth counter in DateTimePrinterContext?

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

PR Comment: https://git.openjdk.org/jdk/pull/26913#issuecomment-3339118873


More information about the core-libs-dev mailing list