Patch: super.clone() and CloneNotSupportedException
Mohan Embar
gnustuff@thisiscool.com
Sun Jul 20 15:17:00 GMT 2003
Hi Jeff,
>> As an aside, is there any way to copy a gnu.gcj.RawData instance in
>> Java without using clone()
>
>You cannot invoke clone() on a RawData field, or any other methods for
>that matter. There's no such thing as a "RawData instance", and the field
>may not even contain a pointer at all.
Thanks for looking at this.
My wording was poor. If an instance has a RawData member, then cloning
that instance presumably correctly clones the RawData field, right?
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.
As an aside, I don't know much about RawData, so, for fun, I
experimented with this:
--------------------------8<----------------------------
import gnu.gcj.RawData;
public class WereGoingDown extends RawData
{
public final Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{}
}
}
--------------------------8<----------------------------
I got this (on MingW32 GCJ 3.4):
--------------------------8<----------------------------
D:\temp>gcj -C WereGoingDown.java
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
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
--------------------------8<----------------------------
Does anyone know or care about this?
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
More information about the Java-patches
mailing list