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


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


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