RFR: JDK-8285932 Implementation of JEP-430 String Templates (Preview) [v13]

Rémi Forax forax at openjdk.org
Wed Nov 9 21:57:53 UTC 2022

On Sat, 5 Nov 2022 22:23:23 GMT, Rémi Forax <forax at openjdk.org> wrote:

>> 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>.

> raw List ?

oops, formatting issue.

The idea is that `values` can be typed `List<?>` because the call to List.copyOf() will take the `List<?>` and return a `List<Object>`.

And as a type of a parameter `List<?>` is better than `List<Object>` because `List<String>` is a subtype of `List<?>` but not a subtype of `List<Object>`.


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

More information about the compiler-dev mailing list