Search code examples
gwtclone

gwt: How do I write a clone() method that doesn't result in "The method clone() is undefined for the type Object" error?


I'm using GWT 2.4. I have this class, which overrides the clone() method ...

public class Attribute implements Serializable, Cloneable {
    ...

public Object clone() {
    Object ret = null;
    try {
        ret = super.clone();
    } catch (CloneNotSupportedException e) {
    }   // try
    return ret;
}

Sadly, when I try and run my GWT test class, I get the compilation error

[ERROR] Line 113: The method clone() is undefined for the type Object

Anyone know how I can rewrite the above to avoid the compile errors while preserving the functionality? Thanks, - Dave


Solution

  • Object.clone is not supported by the GWT compiler. If you really need support for it you can follow a work around suggested in this GWT issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=5068