Trust final fields in records

Chris Hegarty chris.hegarty at
Tue Jun 16 11:08:42 UTC 2020

> On 16 Jun 2020, at 11:08, Kasper Nielsen <kasperni at> wrote:
>> One alternative might be an implicit static method parallel to the
>> constructor that
>> sets all field values, but does not execute any explicit constructor(s),
>> if present.
>> Sort of a 'raw' constructor.
> Not having a 'raw' constructor that breaks encapsulation is a feature,
> not an oversight [1].

Exactly. The creation of deserialized record objects through an invocation of the canonical constructor is intentional. That is the whole point of the Serializable records work [*].



> /Kasper
> [1]

More information about the valhalla-dev mailing list