Object-oriented programming gives us considerable freedom. An object can have an identity, encapsulate mutable state and change its behaviour over time. That model suits many concepts in business software: a customer, order or insurance claim usually has a lifecycle and remains recognisable even as its properties change.
Many other concepts are simply values. A monetary amount, article number, date range, delivery address or search criterion is defined entirely by its data. Two instances containing the same values should normally be interchangeable. Giving such data unnecessary identity and mutation makes the application harder to reason about.
In the Inside Java podcast episode “Immutable Data Beyond Value Classes”, Nicolai Parlog and Java language architect Dan Smith discuss how several Java features are converging around this distinction. Records, value classes, derived record creation, flexible constructor bodies and lazy constants each solve different problems, but together they provide a more expressive toolkit for immutable data.
Records already demonstrate the benefits. They remove much of the ceremony required for small data carriers and provide accessors, equality, hashing and string representation based on their components. That makes them well suited to API models, commands, events, database projections and configuration. Their components cannot be reassigned, although referenced objects must themselves be immutable if deep immutability is required.
Derived record creation extends this model with with expressions. Instead of modifying a record or manually repeating every constructor argument, an application can derive a new value while changing selected components. This fits business workflows in which data passes through validation, enrichment and transformation steps. Each stage produces a new, explicit state without altering the value received by the previous stage.
Value classes go deeper. They allow a class to declare that its instances do not depend on object identity. This communicates an important modelling decision to both developers and the JVM: the state is what matters. In the future, the runtime may also represent and process such values more efficiently.
Flexible constructor bodies make it easier to validate and prepare data during construction, while lazy constants provide thread-safe, one-time initialization for values whose creation should be deferred. These features support immutable designs without requiring every application to build its own supporting utilities.
Spring applications still need a clear boundary between values and entities. A JPA entity usually has database identity, a managed lifecycle and framework requirements that make records or value classes unsuitable as direct replacements. Immutable types are most useful around those entities: in API boundaries, application commands, events, projections and domain value objects.
The broader lesson concerns modelling rather than syntax. When a concept is defined entirely by its contents, expressing it as immutable data makes that meaning visible in the code. Java’s emerging feature set can make business applications clearer, reduce accidental state changes and provide safer foundations for concurrent processing.