RFR: 8316704: Regex-free parsing of Formatter and FormatProcessor specifiers [v3]

Shaojin Wen duke at openjdk.org
Fri Oct 20 11:07:44 UTC 2023


On Fri, 20 Oct 2023 08:52:04 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   fix FormatterBuilder testcase handle lineSeparator on windows
>
> src/java.base/share/classes/java/util/FormatProcessor.java line 247:
> 
>> 245:                 throw new MissingFormatArgumentException(group + " is not immediately followed by an embedded expression");
>> 246:             } else {
>> 247:                 throw new UnknownFormatConversionException(String.valueOf(c));
> 
> I don't think this exception is thrown by the original code.

I added these tests to show that the exceptions and messages thrown are the same as before.


// test/jdk/java/lang/template/FormatterBuilder.java
assertThrows(
        MissingFormatArgumentException.class,
        () -> fmt. "%10ba{ false }",
        "Format specifier '%10b is not immediately followed by an embedded expression'");

assertThrows(
        MissingFormatArgumentException.class,
        () ->fmt. "%ba{ false }",
        "Format specifier '%b is not immediately followed by an embedded expression'");

assertThrows(
        MissingFormatArgumentException.class,
        () ->fmt. "%b",
        "Format specifier '%b is not immediately followed by an embedded expression'");
assertThrows(
        UnknownFormatConversionException.class,
        () ->fmt. "%0",
        "Conversion = '0'");

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15776#discussion_r1366829200


More information about the core-libs-dev mailing list