[Records] Why components are not readOnly

Bruno Borges bruno.borges at gmail.com
Tue Jan 21 09:48:26 UTC 2020


Hi,

A field that is static and final is by definition, readOnly [1]. See this
sample [2] for a comparison between Java 1.8 and 11 versus 13 and 14.

Is there a reason why Record components aren't protected from basic
reflection access and modification as static final constants are? And what
could be the possible downsides of turning Record components into readOnly?

[1]
https://github.com/openjdk/jdk14/blob/master/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorFactory.java#L38
[2] https://asciinema.org/a/grviUuzbf3IViR08FqHxC79WE

---
*Bruno Borges*


More information about the amber-dev mailing list