[jdom-interest] Moving Children

Frank Sauer Frank.Sauer at trcinc.com
Fri Jun 15 13:36:14 PDT 2001

Sorry, you guys are correct. As I said, it WAS
a long night....

How about using reflection?

Method c = = whatever.getClass().getMethod(...... <clone> ....)

Would that work?

Frank Sauer
The Technical Resource Connection, Inc.
a wholly owned subsidiary of Perot Systems
Tampa, FL
Java: The best argument for Smalltalk since C++

-----Original Message-----
From: Alex Rosen [mailto:arosen at silverstream.com]
Sent: Friday, June 15, 2001 4:17 PM
To: 'Frank Sauer'; 'Jason Hunter'; 'Eric Rosenberg'
Cc: 'Jdom-Interest'
Subject: RE: [jdom-interest] Moving Children

> 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
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.


More information about the jdom-interest mailing list