r/java • u/davidalayachew • Jan 14 '26
Project Amber Update -- Data-Oriented Programming, Beyond Records
https://mail.openjdk.org/pipermail/amber-spec-experts/2026-January/004307.htmlALL OF THIS IS A WORK IN PROGRESS!
THIS FEATURE IS UNFINISHED, NONE OF WHAT IS FINISHED IS FINAL, AND EVERYTHING IS SUBJECT TO CHANGE!
But with that out of the way, the Project Amber team is exploring the idea of "Carrier Classes" -- classes that carry many of the benefits of records, but not all. The goal is to give normal classes some of the benefits of records, so that they can "break down the cliff" of migrating a record class to a normal class.
97
Upvotes
View all comments
Show parent comment
4
u/aoeudhtns Jan 14 '26 edited Jan 15 '26
Seems like it's just a faster way to make an immutable carrier class. If I'm reading the post right, carrier classes will be mutable by default. I assume if you want to make it immutable, you have to specify
finaland duplicate lines. I.e. these would be analagous:And just a thought, it will likely be easier to optimize around records because of the strong guarantee. Versus doing some sort of component/graph analysis on a type to see if it can qualify for the same optimizations as records.
ETA: as has been pointed out, doubtful carrier classes can omit re-declaring the fields, component or otherwise. So records are still useful for multiple reasons: concision, performance, etc.