All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Acme.GenericCloneable


public class GenericCloneable
extends Object
implements Cloneable
A convenience parent for Cloneable classes.

In the current JDK, the API for cloning is slightly broken. The intent was for classes that didn't need to clone any sub-objects to be able to just add an "implements Cloneable" and have everything work. However, as it stands now, such classes still need to implement a clone method.

What's annoying is that all of these no-sub-objects clone methods are completely identical. Every one of them looks like this:

 public Object clone()
         return super.clone();
     catch ( CloneNotSupportedException e )
         // Shouldn't happen.
         throw new InternalError( e.toString() );
Well, what this class does is implement that clone method. If your class doesn't need to have anything else as parent (true for "struct" classes), then just make GenericCloneable the parent and presto, you're cloneable.

Fetch the software.
Fetch the entire Acme package.

Constructor Index

 o GenericCloneable()

Method Index

 o clone()


 o GenericCloneable
 public GenericCloneable()


 o clone
 public Object clone()
clone in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs