> 3. copy/clone
I agree that this needs to be fixed. I don't like the suggested
fix though. I don't think it is a good idea to "magically" provide
the native method implementation. What if instead we do the following.
define an empty interface called Cloneable:
interface Cloneable {}
provide the following methods in class Object:
public native Object clone(Cloneable obj);
public native void copy(Cloneable from, Cloneable to);
Note that these methods can only be used on objects that are
declared to implement the Cloneable interface.
Yes, this is a great solution. I would argue, however, that we should
adopt this solution *only* for the clone method. The copy method is
dangerous, misleadingly named, and not really used in practice anyway.
I say, nuke it!
--Guy
I agree that this needs to be fixed. I don't like the suggested
fix though. I don't think it is a good idea to "magically" provide
the native method implementation. What if instead we do the following.
define an empty interface called Cloneable:
interface Cloneable {}
provide the following methods in class Object:
public native Object clone(Cloneable obj);
public native void copy(Cloneable from, Cloneable to);
Note that these methods can only be used on objects that are
declared to implement the Cloneable interface.
Yes, this is a great solution. I would argue, however, that we should
adopt this solution *only* for the clone method. The copy method is
dangerous, misleadingly named, and not really used in practice anyway.
I say, nuke it!
--Guy