r/java • u/davidalayachew • Jan 06 '26
One step closer to Value Classes!
https://mail.openjdk.org/pipermail/porters-dev/2026-January/000844.html
181
Upvotes
r/java • u/davidalayachew • Jan 06 '26
View all comments
Show parent comment
2
u/joemwangi Jan 06 '26
Recently, I realised this is a classic pitfall of mutable structs in C#. If an object has both a primitive field, struct field and a reference field, mutating them inside a method only updates the reference field and the direct primitive field; the struct field is mutated on a copy.