Patch: super.clone() and CloneNotSupportedException
Jeff Sturm
jsturm@one-point.com
Sun Jul 20 15:57:00 GMT 2003
On Sun, 20 Jul 2003, Mohan Embar wrote:
> 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;
}
}
BTW, I prefer copy methods to copy constructors, since you then have the
choice of implementing them with clone() for convenience.
> WereGoingDown.java:3: error: Can't subclass final classes: gnu.gcj.RawData.
> public class WereGoingDown extends RawData
> ^
> WereGoingDown.java:0: internal compiler error: tree check: expected class 'd', h
> ave 'x' (identifier_node) in check_inner_circular_reference, at java/parse.y:520
> 6
> Does anyone know or care about this?
RawData is final, so the code is illegal. Gcj doesn't always recover
gracefully from errors. (Neither does jikes, for that matter.)
It's worth fixing but not as important as an ICE compiling legal code
(meaning nobody will probably get to it soon). Feel free to enter a PR
anyway.
Jeff
More information about the Java-patches
mailing list