[jdom-interest] Moving Children

Alex Rosen arosen at silverstream.com
Fri Jun 15 13:16:59 PDT 2001


> Maybe I'm completely confused (it has been a long night)
> but if you call :
>
> 	((Object)whatever).clone();
>
> won't that result in a call to the actual overridden clone() in the
> actual class of whatever?

No, it will give you a compiler error. No matter what object "whatever" is at
runtime, you're calling it as an Object, and Object.clone() is protected.

Sun has acknowledged that clone() is screwed up. No matter what you try, you
can't clone an object unless you know its type beforehand (at compile-time).
See http://developer.java.sun.com/developer/bugParade/bugs/4098033.html.

Alex




More information about the jdom-interest mailing list