RFR: JDK-8285932 Implementation of JEP-430 String Templates (Preview) [v3]
    Franz Wilhelmstötter 
    duke at openjdk.org
       
    Fri Oct 28 20:01:29 UTC 2022
    
    
  
On Fri, 28 Oct 2022 19:21:56 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:
>> 
>>   Update TemplateRuntime::combine
>
> src/java.base/share/classes/java/lang/template/TemplateRuntime.java line 211:
> 
>> 209:     @SuppressWarnings("unchecked")
>> 210:     public static <E> List<E> toList(E... elements) {
>> 211:         return Collections.unmodifiableList(Arrays.asList(elements));
> 
> This is List.of(), please use List.of() instead
`List.of()` can't be used here, since the elements are nullable, according to the documentation. But the the returned list can still be modified, by changing the given `elements` array. The input array must be explicitly copied:
public static <E> List<E> toList(E... elements) {
	return Collections.unmodifiableList(new ArrayList<>(Arrays.asList(elements)));
}
-------------
PR: https://git.openjdk.org/jdk/pull/10889
    
    
More information about the security-dev
mailing list