MCPcopy Create free account
hub / github.com/SquirrelJME/SquirrelJME / clone

Method clone

runt/apis/cldc-compact/java/lang/Object.java:48–70  ·  view source on GitHub ↗

Clones the current copy creating a shallow copy of it if Cloneable is implemented, unless this method is overridden to perform class specific cloning. @throws CloneNotSupportedException If cloning is not supported by the current class, the default implementation always throws this if the {@

()

Source from the content-addressed store, hash-verified

46 * @since 2016/02/08
47 */
48 protected Object clone()
49 throws CloneNotSupportedException
50 {
51 // If this is an array copy elements around
52 Class<?> cl = this.getClass();
53 if (cl.isArray())
54 {
55 // Need length of this array to recreate!
56 int len = ObjectAccess.arrayLength(this);
57
58 // Allocate new array
59 Object dest = ObjectAccess.arrayNew(cl, len);
60
61 // Copy everything over
62 System.arraycopy(this, 0, dest, 0, len);
63
64 // This array was cloned
65 return this;
66 }
67
68 // {@squirreljme.error ZZ0u This object does not support being clone.}
69 throw new CloneNotSupportedException("ZZ0u");
70 }
71
72 /**
73 * Checks for equality between this object and another. Equality should be

Callers

nothing calls this directly

Calls 5

getClassMethod · 0.95
arrayLengthMethod · 0.95
arrayNewMethod · 0.95
arraycopyMethod · 0.95
isArrayMethod · 0.45

Tested by

no test coverage detected