copying: deep vs shallow copy module (clone() traps, copy constructors, serialization copy, records, defensive copies, collection copies), 17 contract tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4X2xx7RrveVQU9R1N
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
== 1. A full deep copy: nothing is shared ==
|
||||
copy.dept == asha.dept : false
|
||||
copy.skills == asha.skills : false
|
||||
asha.skills = [java, spring], asha.dept = Core
|
||||
copy.skills = [java], copy.dept = Platform
|
||||
|
||||
== 2. transient fields are lost ==
|
||||
asha.sessionToken = secret-token
|
||||
copy.sessionToken = null
|
||||
|
||||
== 3. Sharing INSIDE the graph is preserved ==
|
||||
original: same Dept object : true
|
||||
copy : same Dept object : true
|
||||
copy dept is a new object : true
|
||||
|
||||
== 4. Cycles are handled ==
|
||||
cyc.mentor.mentor == cyc : true
|
||||
cyc != asha : true
|
||||
|
||||
== 5. A non-serializable field fails at run time ==
|
||||
NotSerializableException: java.lang.Object
|
||||
Reference in New Issue
Block a user