On Mon, 8 Jun 2026 20:55:00 GMT, Justin Lu <[email protected]> wrote: > ListFormat validates patterns before passing them to MessageFormat, but it > currently allows single quotes as is. MessageFormat interprets these as > escaping syntax, which can lead to incorrect output. For example, given the > end pattern `"{0}'{1}'"` and an empty two pattern, a `ListFormat` formats > `List.of("foo", "bar")` as `"foo{1}"` instead of `"foo'bar'"`. > > This behavior violates the specification, as ListFormat does not define any > escaping mechanisms. This PR converts ListFormat patterns to the > corresponding MessageFormat pattern by ensuring all single quotes are > doubled, such that they are always treated literally by the MessageFormat. I > intentionally handle the replacement logic at the MessageFormat creation site > instead of the existing ListFormat validation, because the patterns should > remain exactly the same as the input given by the user. > > I am treating this as a normal bug fix since the current behavior violates > the specification and is incorrect. No one should be relying on this type of > behavior. However, I can file a CSR if deemed necessary. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
LGTM. I also agree that this is simply a bug fix, since the use of MessageFormat is an implementation detail. Providing a release note may be appropriate because this change corrects the behavior, but I’m also fine without one. That said, I think the JBS issue should focus on the incorrect behavior itself rather than on “tightening” the implementation. The affected versions should also include JDK 22, since this behavior was first introduced there. ------------- Marked as reviewed by naoto (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/31430#pullrequestreview-4454031253
