On Sat, 20 Sep 2025 14:39:20 GMT, Shaojin Wen <[email protected]> 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:
> 
>   Improve code style in DateTimeFormatterBuilder.format method
>   
>   Co-authored-by: Qwen-Coder <[email protected]>

This change proposes to make every PrinterParser necessarily handle the 
optionality that is supported by a few printer parsers. For some, like 
literals, it makes no sense at all. It adds complexity to the PrinterParser 
interface.
The optionality for nesting of printer parsers is currently handled by counting 
the depth in the DateTimePrintContext.
Is there another way that the optionality in a DateTimeContext can be passed on 
nesting without adding an argument everywhere?  Supposing the optional field in 
DateTimePrintContext could be `final boolean` and when optionality is needed, a 
copy be made with `optional = true` and passed to the nested printer. This 
technique is already used for `appendOptional`.

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

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

Reply via email to