RFR: 8301220: Return value of toArray() of Сollection types from java.base should be trusted [v3]

Tingjun Yuan duke at openjdk.org
Mon Jan 30 03:00:19 UTC 2023


On Mon, 30 Jan 2023 02:55:24 GMT, Glavo <duke at openjdk.org> wrote:

>> I checked the `java.base` module, and all the `Collection#toArray()` method of collections be implemented correctly.
>> 
>> Their return values can be trusted, so many unnecessary array duplication can be eliminated.
>
> Glavo has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add trusted collection list

src/java.base/share/classes/java/util/Collections.java line 5838:

> 5836:     }
> 5837: 
> 5838:     private static final Set<String> trustedCollections = Set.of(

Why not use set of classes?

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

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


More information about the core-libs-dev mailing list