QUOTE(1lacca @ 17 Sep, 2007 - 09:58 PM)

Actually I think the clone method inherited from the Object class already does this (copies all fileds), so it is a bit NIH, however in the inheritance tree all classes must override the clone method - so if it is not done, or you don't have access to the given class, it might work. (See the API for the Object.clone() method)
On the other hand, if the set method does some conversion on the values it receives(and it is not written to the field as it is), than probably the clone won't be a real clone.
Anyway, apart from this disclaimer it can be a useful utility if used correctly.
Yes, Object.clone() is a natively implemented shallow copy, but, as you said, all classes in a hierarchy must implement clone (this is a soft requirement). My method removes this requirement by recursing through all superclasses of the class passed in. But the main focus of the article was using Reflection to automate tasks like cloning. I suppose I could have used a different task, but I thought this demonstrated it well in the very limited time that I had. In fact, in the article I suggest that the reader "fidget" with the code to create a deep copy version of clone (Something witch Object.clone() does not do). I also alluded that I
might blog about how to do that later, time permitting. We'll see. As far as I know, Field.set does not do any conversion that would cause a problem with clone equality. But thanks for your input.