On Wed, 23 Nov 2022 13:55:38 GMT, Jim Laskey <jlas...@openjdk.org> wrote:

>> Enhance the Java programming language with string templates, which are 
>> similar to string literals but contain embedded expressions. A string 
>> template is interpreted at run time by replacing each expression with the 
>> result of evaluating that expression, possibly after further validation and 
>> transformation. This is a [preview language feature and 
>> API](http://openjdk.java.net/jeps/12).
>
> Jim Laskey has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Update @since

src/java.base/share/classes/java/util/FormatProcessor.java line 85:

> 83: 
> 84:     /**
> 85:      * {@inheritDoc}

The javadoc should describe in more detail what `process` does and the errors 
than can occur.
That will help developers understand the errors that come out of Formatter in 
the context of FMT.
That will help even if that is just to describe how the format string passed to 
j.u.Formatter is constructed.
The javadoc should warn that the fragment should contain only a single format 
string and it must be at the end of the fragment.
For example, if multiple format strings appear in the fragment they are all 
passed to Formatter.
If the last format string is not the last in the fragment (for example, 
followed by a space) then a %s is appended and there are two formatters for a 
single value.  For example,

   int x = 1;
   FMT."x: %s {x}";  // extra space

It is unfortunate that the exception reported (in the case of a mismatch in the 
number for format strings vs values) is a BootStrapMethodError with a cause of 
MissingFormatArgument.  That's exposing the implementation and may look like a 
bug in the FMT.

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

PR: https://git.openjdk.org/jdk/pull/10889

Reply via email to