[ 
https://issues.apache.org/jira/browse/JCR-1423?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572942#action_12572942
 ] 

Jukka Zitting commented on JCR-1423:
------------------------------------

This change breaks test cases.

I suspect the reason to be that "new ThisClass()" is not the same as 
"(ThisClass) super.clone()". The latter copies all field values as-is, so for 
example all reference variables in the cloned object point back to components 
of the original object instead of being freshly initialized.

Why do we even need clone()? IMHO a copying constructor is much better solution 
for cloning objects. 

> [PATCH] fix clone implementation
> --------------------------------
>
>                 Key: JCR-1423
>                 URL: https://issues.apache.org/jira/browse/JCR-1423
>             Project: Jackrabbit
>          Issue Type: Improvement
>          Components: jackrabbit-core, jackrabbit-jcr2spi
>            Reporter: Dave Brosius
>            Priority: Trivial
>             Fix For: 1.5
>
>         Attachments: fix_clone_impl.patch
>
>
> Several classes implement clone, by doing new XXXX() to create the object. As 
> these classes aren't final, this will fail if these classes are ever derived 
> from (which they are not, right now). The correct implementation is to call 
> super.clone(). This patch fixes this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to