Manifest copy constructor does not deeply copy individual section Attributes

Philipp Kunz philipp.kunz at paratix.ch
Sat Jan 19 19:34:44 UTC 2019


Hi again,
Just after having sent the previous mail I found Manifest::clone
explicitly says it creates a shallow copy which is true only to a
certain extent. It deeply copies main attributes as well as individual
sections map already now and only shallowly copies individual sections
attributes maps.
I don't know about the background of it or why clone should only do a
shallow copy but if clone should really create a shallow copy, it
should probably create an even more shallow copy. In any case I figure
some potential for clarification at least.
Probably mostly because I already began a patch in the previous
message, I continued and attached another patch for a deep copy
approach. There might still be some reason not to deeply copy manifests
which I don't intend to forestall.
Philipp

On Sat, 2019-01-19 at 19:32 +0100, Philipp Kunz wrote:
> Hi,
> 
> Creating a new manifest as a copy from an existing one using the copy
> constructor assigns the new manifest individual sections entries map
> the same values which are references to attributes as the original
> rather than copying them as well deeply resulting in two manifests
> pointing to the same attributes instances modifications to which
> always affect both manifests. See test and proposed fix in the
> attached patch.
> 
> Regards,
> Philipp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: manifestcopyconstructorandclone.patch
Type: text/x-patch
Size: 7429 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20190119/6d111f27/manifestcopyconstructorandclone-0001.patch>


More information about the core-libs-dev mailing list