[PATCH] 8173962: Add API for Deep copy of multi-dimensional arrays

Fabio Romano fabio19298 at gmail.com
Wed Jan 11 12:45:02 UTC 2023


Added the methods deepCopyOf(U[] original, Class<? extends T[]> newType)
and deepCopyOf(T[] original), that perform a deep copy of the structure of
multidimensional arrays. Also, added a pre-calculation of the string
builders capacity for toString() of primitive array types, based on the
mold of BitSet.toString() method for pre-calculation of the initial
capacity.

The deep copy is necessary for coping a multiarray that should be assigned
to a field or returned by a getter method, to ensure that the data
structure will not be modified externally of the class.

The pre-calculation of the string builders capacity is an optimization to
reduce the times that builders needs to grow their capacity.

Link to the pull request: https://github.com/openjdk/jdk/pull/11815
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20230111/d1cc5ced/attachment.htm>


More information about the jdk-dev mailing list