RFR: 8323699: MessageFormat.toPattern() generates non-equivalent MessageFormat pattern [v3]
Justin Lu
jlu at openjdk.org
Wed Jan 24 00:00:26 UTC 2024
On Tue, 23 Jan 2024 23:12:19 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
>> test/jdk/java/text/Format/MessageFormat/MessageFormatToPatternTest.java line 96:
>>
>>> 94: @ParameterizedTest
>>> 95: @MethodSource("testCases")
>>> 96: public void testRoundTrip(MessageFormat format1) {
>>
>> Can we also include the original String pattern that created format1, to help with debugging. I find myself wondering what the original String was.
>>
>> Since technically, the full round trip is _pattern string -> MessageFormat1 -> pattern string -> MessageFormat2_
>
> I would have done that but it's not (easily) possible. The `MessageFormat`'s are created not from format strings, but by piecing together plain text and sub-`Format` objects manually. This was we are sure what we're dealing with.
>
> Trying to create format strings with multiple levels of nesting from scratch is too complex for my brain due to all the levels of quoting required.
Right, should have noted that, definitely not worth to try and re-synthesize the original String pattern for each Format. If we're adding some additional concrete cases, its fine since those will clearly have the original String patterns there.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17416#discussion_r1464131694
More information about the core-libs-dev
mailing list