On Fri, 20 Oct 2023 11:04:28 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> 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'");

I'm referring specifically to this method, regardless of the tests.

The invocation `findFormat("%0", <any>)` simply returns `false` in the original 
code, but throws in the proposed code.
It's way easier to be confident that a local re-implementation, as done here, 
is correct if the behavior is externally the same.

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

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

Reply via email to