5

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

Dave
  • 15,639
  • 133
  • 442
  • 830

1 Answers1

4

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

Strelok
  • 50,229
  • 9
  • 102
  • 115
  • This answers the question, but here is a link as an alternative solution to clone() (for the folks who stumbled here looking for a solution since clone() won't work): https://stackoverflow.com/a/49248240/2129418 – Jason Washo Mar 13 '18 at 04:15