T
Thomas G. Marshall
Does anyone know why the java designers didn't make every object
shallow-cloneable by default?
I understand the implications of cloning something overly hefty, and to be
cautious about such things, but it still seems a little overboard to me to
err on the side of turning if off.
Turning it off could easily have been accomplished by implementing something
called:
public interface NotCloneable {}
In fact, I might have allowed two methods, deep within Object:
public Object shallowClone()
and
public Object deepClone()
Now deep cloning is of course fraught with peril, and I am normally very
much in favor of the safety restrictions in the java language, but I'm not
sure this is the kind of thing that java should protect against.
shallow-cloneable by default?
I understand the implications of cloning something overly hefty, and to be
cautious about such things, but it still seems a little overboard to me to
err on the side of turning if off.
Turning it off could easily have been accomplished by implementing something
called:
public interface NotCloneable {}
In fact, I might have allowed two methods, deep within Object:
public Object shallowClone()
and
public Object deepClone()
Now deep cloning is of course fraught with peril, and I am normally very
much in favor of the safety restrictions in the java language, but I'm not
sure this is the kind of thing that java should protect against.