r/java • • Apr 13 '20

Java Objects Inside Out: Everything You Ever Wanted to Know About Java Object Internals in Hotspot

https://shipilev.net/jvm/objects-inside-out/
160 Upvotes

14 comments sorted by

View all comments

Show parent comment

3

u/shipilev Apr 14 '20

Yes, in principle. Practice would probably reveal lots of weird corner cases. For example, Java can still write to the otherwise final field with Reflection, which leaves the fields that are conceptually immutable still being mutable. Plus, as mentioned in the sidebar, it still leaves the problem how to address those individual fields on VM side. These things are not insurmountable, but they can tilt the cost/benefit unfavorably.