commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CLI-21) [cli] clone method in Option should use super.clone()
Date Fri, 15 Jun 2007 15:55:26 GMT

    [ https://issues.apache.org/jira/browse/CLI-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505282
] 

Henri Yandell commented on CLI-21:
----------------------------------

Patch applied - thanks for doing that Brian.

One question - when cloning, should the effects of addValue/processValue be undone?

ie) Rather than:

        option.values = new ArrayList(values);

it should be:

        option.values = new ArrayList();

Or should we just recommend in the javadoc for clone() that people will probably want to immediatley
call clearValues()?

> [cli] clone method in Option should use super.clone()
> -----------------------------------------------------
>
>                 Key: CLI-21
>                 URL: https://issues.apache.org/jira/browse/CLI-21
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x
>    Affects Versions: 1.0
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Nathan McDonald
>             Fix For: 1.1
>
>         Attachments: bug21.patch
>
>
> In
> org.apache.commons.cli.Option
> public method clone is implemented by creating a new instance through one of 
> the class Constructors, and then assigning values as required through the 
> setter methods.
> This means that any subclasses of the Option class will not return a true 
> clone, but a new Option instance instead.
> A proper implementation of clone should use super.clone() to create a new 
> instance, rather than calling the class constructor.  This allows shallows 
> clones to propogate correctly down to subclasses.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message