[Records] Why components are not readOnly

Valentin Kovalenko valentin.male.kovalenko at gmail.com
Wed Jan 22 00:04:05 UTC 2020

> Brian
> remember that modifying final fields is wholly outside of either the
language or VM specification

Not that I am advocating for "tacking weird corner-case behavior in a dozen
different places", but JLS does have a whole paragraph talking about
modification of final fields via reflection and other
implementstion-dependent mechanisms.

JLS 15.5.3 says: "final fields can be changed via reflection and other
implementstion-dependent means". So even if the ability to write final
fields via reflection is considered to be implementation-dependent (which
it is according to the specification of the Field.set method), the JLS
explicitly allows that to happen and specifies the behaviour of such
writes: "Freezes of a final field occur ... immediately after each
modification of a final field via reflection".


More information about the amber-dev mailing list