On Wed, 8 Sep 2021 02:10:36 GMT, David Schlosnagle 
<github.com+54594+schlo...@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]);

Thank for suggestion. Updated.

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

PR: https://git.openjdk.java.net/jdk/pull/5261

Reply via email to