This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: super.clone() and CloneNotSupportedException


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/





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]