Richard Groß

IT Archaeology: Mend Software · Create Options · Increase ROI

RSS

Talks

2026-10-05 - Devoxx Belgium

javadestructoringencapsulation

Destructoring is the future of Javas Encapsulation

Code
Destructoring—the breakdown of an object into its constituent parts—isDestructoring—the breakdown of an object into

Destructoring—the breakdown of an object into its constituent parts—is key to Java's ability to reliably maintain encapsulation and invariants. We resolve this apparent paradox in the presentation by looking at past and future language and platform features in the JDK. Classic Java serialization breaks encapsulation: it directly accesses private fields, thereby bypassing constructors and the checks anchored there. The reason for this is that deconstruction and reconstruction have not been first-class citizens in the JDK until now. This is precisely where current work within the JDK Project Amber comes in – under the working title “Derived Record/Class Creation.” This approach allows us to explicitly specify how objects are deconstructed and reconstructed. This will not only make serialization more secure and robust in the future, but we will also gain “withers” (targeted, immutable copies with individual modified components) for records and pattern matching, which will be extended beyond pure record patterns to normal classes. Given these circumstances, it is worth taking a closer look: What is already there, what comes next – and what does this mean for our daily Java practice?

Give Feedback

What worked for you? What could be better? I’d love to hear your thoughts.

Give feedback via

BlueSky LinkedIn

Grab a coffee

Questions or ideas after the talk? Book a virtual coffee with me.

Grab a coffee

Additional links

  • JEP 500: Prepare to Make Final Mean Final jep-500

Post on Mastodon

Choose your Mastodon instance or type its domain. Your post will open in a new tab.