Brian Goetz, lead of Project Amber, has outlined a new concept called carrier classes as a generalization of Java records. Carrier classes maintain the external commitment of a state description (accessors, deconstruction pattern, symmetrical constructor) but drop the internal commitment that fields must match the API, and do not require immutability. They support component fields as a shortcut for the common case where external API maps directly to internal representation, while allowing custom backing for the rest. Records are reframed as a stricter variant of carrier classes where every component is a final component field. The proposal also touches on abstract records, prefix patterns for more flexible deconstruction, and hints that custom deconstruction pattern syntax may never arrive. Additionally, JEPs for pattern assignments and constant patterns are being drafted.
Sort: