This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: super.clone() and CloneNotSupportedException
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Mohan Embar <gnustuff at thisiscool dot com>
- Cc: java-patches at gcc dot gnu dot org, Anthony Green <green at redhat dot com>
- Date: Sun, 20 Jul 2003 11:57:36 -0400 (EDT)
- Subject: Re: Patch: super.clone() and CloneNotSupportedException
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