Patch: super.clone() and CloneNotSupportedException
Mohan Embar
gnustuff@thisiscool.com
Sun Jul 20 16:11:00 GMT 2003
Hi Jeff,
>> If that's the only way you can copy the field into another instance,
>> then my suggestion to replace clone() with a copy constructor
>> would be doomed.
>
>Why can't you assign a RawData field in Java? The following compiles:
>
>class A {
> gnu.gcj.RawData x;
>
> A copy() {
> A a = new A();
> a.x = this.x;
> return a;
> }
>}
I thought about this, but I don't know enough about gcj internals to
understand whether this works or not. For someone like me who doesn't
know too much about gcj, x looks like an object reference, so the above
code would be incorrect because you'd be creating a shallow copy of x
instead of a deep copy.
>BTW, I prefer copy methods to copy constructors...
Me too.
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
More information about the Java-patches
mailing list