On Wed, 16 Nov 2022 20:25:30 GMT, Roger Riggs <[email protected]> wrote:
>> Jim Laskey has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Wrong line separator
>
> src/java.base/share/classes/java/lang/template/StringTemplateImplFactory.java
> line 202:
>
>> 200: @SuppressWarnings({"unchecked", "varargs"})
>> 201: private static <E> List<E> toList(E... elements) {
>> 202: return Collections.unmodifiableList(Arrays.asList(elements));
>
> Is a defensive copy needed here?
> The caller of `newStringTemplate` could retain a reference to the Object[]
> array and modify it later.
Alternatively,
`SharedSecrets.getJavaUtilCollectionAccess().listFromTrustedArrayNullsAllowed(elements)`
(or `elements.clone()`) could be used here, to reduce amount of wrappers.
-------------
PR: https://git.openjdk.org/jdk/pull/10889