Closed kjy5 closed 3 months ago
Hi, and thanks a lot for the report.
Maybe it's a bug, maybe it's a feature :-) but it's clearly inconsistent with the documentation.
With the code you propose, it would not be a deep copy anymore since the metadata objects would be shared. However, deep copying arbitrary objects in Java is tough, so maybe it's best to leave it this way (not copying anything) and document it? I am not sure what's best.
Cheers.
Ah, that's a good point. I wasn't putting objects in the metadata so this would've worked for my purposes. Yes, I think a documentation update would probably make more sense here.
The JavaDoc for
deepCopy
saysBut it's unclear what "Deep copy of node" means. The default behavior of
deepCopy
does not copy metadata which seems unintuitive since the purpose of the function is to make a faithful copy of the tree.This can be fixed by adding
to the implementations, so that makes me think not including this was on purpose. Why?
I came across this issue when I tried using
deepCopy
with the expectation that metadata was copied over but I was surprised when it wasn't. I'm using the above code to fix this in my usage.