On Thu, 26 Aug 2021 06:19:49 GMT, Andrey Turbanov <github.com+741251+turban...@openjdk.org> wrote:
> In [JDK-8268873](https://bugs.openjdk.java.net/browse/JDK-8268873) I missed a > few places, where Vector could be replaced with ArrayList. > Usage of thread-safe collection `Vector` is unnecessary. It's recommended to > use `ArrayList` if a thread-safe implementation is not needed. src/java.base/share/classes/javax/crypto/CryptoPermissions.java line 348: > 346: CryptoPermission[] ret = new CryptoPermission[permVector.size()]; > 347: permVector.copyInto(ret); > 348: return ret; Should this return the result of `toArray` for safety (though it is sized correctly so per API should return the same `ret` array). Suggestion: CryptoPermission[] ret = new CryptoPermission[permList.size()]; return permList.toArray(ret); Separate perf nit would be to use size zero array as arg to `toArray` per https://shipilev.net/blog/2016/arrays-wisdom-ancients/ Suggestion: return permList.toArray(new CryptoPermission[0]); ------------- PR: https://git.openjdk.java.net/jdk/pull/5261