On Thu, 3 Nov 2022 17:23:53 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:
> 
>   Internalize FormatConcatItem

src/java.base/share/classes/java/lang/template/StringTemplate.java line 276:

> 274:      * @implNote Contents of both lists are copied to construct 
> immutable lists.
> 275:      */
> 276:     public static StringTemplate of(List<String> fragments, List<Object> 
> values) {

Should be `StringTemplate of(List<String> fragments, List<?> values) {`

The call to List.copyOf() will change the List<?> to List<Object>.

src/java.base/share/classes/java/lang/template/StringTemplate.java line 299:

> 297:      * @throws NullPointerException fragments or values is null or if 
> any of the fragments is null
> 298:      */
> 299:     public static String interpolate(List<String> fragments, 
> List<Object> values) {

Should be `String interpolate(List<String> fragments, List<?> values) {` as 
above

src/java.base/share/classes/java/lang/template/StringTemplate.java line 305:

> 303:         int valuesSize = values.size();
> 304:         if (fragmentsSize != valuesSize + 1) {
> 305:             throw new RuntimeException("fragments must have one more 
> element than values");

Should be IllegalArgumentException (see method of() above)

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

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

Reply via email to