Hi wenshao,
I think this is a very good proposal that makes code much cleaner. This allows 
us to migrate this context to value classes in the future for better 
optimization, improves the thread safety of the optional status tracking 
(compared to throwing exceptions), and makes the context thread safe.

Regards,
Chen
________________________________
From: core-libs-dev <[email protected]> on behalf of wenshao 
<[email protected]>
Sent: Thursday, September 18, 2025 8:16 PM
To: core-libs-dev <[email protected]>
Subject: Propose to make j.t.f.DateTimePrintContext immutable

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.

In order to make it easier for reviewers to see my ideas, I submitted a draft 
Pull Request ( https://github.com/openjdk/jdk/pull/26913 ). Please give me 
feedback.

Reply via email to