Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4098033

Cloneable doesn't define .clone

XMLWordPrintable

    • generic, x86, sparc
    • generic, solaris_2.5.1, solaris_2.6, windows_nt, windows_xp

      Name: mf23781 Date: 12/09/97


      Cloneable doesn't define clone. This means that programmers cannot
      polymorphically clone objects, such as in:

          for (int i = 0; i < myVector.size(); i++) {
              result.myVector.setElementAt(
                  ((Cloneable) myVector.elementAt()).clone(), i);
          }

      Secondly, programmers have no idea whether clones are deep or shallow.

      Since interfaces cannot be changed, suggested solution:
           add an interface for deep clones:

          public interface interface Copyable {
             public Object clone(); // guarantees deep clone
          }
      ###@###.### 11/3/04 21:17 GMT

            sseligmasunw Scott Seligman (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: