: In article <
[email protected]>, (e-mail address removed) says...
:> : Putting the clone() method in the interface would force public
:> : accessibility to that method, which is not an intended
:> : effect of marking a class as Cloneable.
:>
:> That's a generic problem with using Java interfaces - if you
:> implement them the world and his wife gets to use them - which
:> is not necessarily what the programmer wants.
: Not strictly true. While all members of the interface are public, the
: interface itself may not be. It could have package access or if it were
: nested can even be private or protected.
Fair enough.
This doesn't help much with the clone problem, though.
The Cloneable interface would /have/ to be public - else
you could not access it at all from most classes. However,
you might not want the clone method to be public - since
you may not want everyone to be able to copy your object.
If that sort of pattern is what you are after, you can't
use a method in a Java interface - because all such
methods are forced to be public.
I reckon this is a generic problem with Java interfaces.
It seems as though you ought to use an interface here -
but there are potentially-undesirable side effects on
the scope of the resulting methods.