Bytecode transforming record class to be mutable
Christian Beikov
christian.beikov at gmail.com
Wed Aug 17 14:50:09 UTC 2022
I just saw that EBean does bytecode transformation of record class files
in a way that feels odd to me and I seek an answer about whether this is
legal from a JVM point of view.
Apparently, it is possible to have a class file, where the class extends
`java.lang.Record` and defines record component attributes (so it's a
"record" like javac would create it), but with the following additional
"features" which javac would not allow:
* Make fields for record components non-final
* Add additional fields that are not set through the canonical
constructor, nor exposed through record component attributes
To me, this seems illegal and I would have expected a JVM verification
error. I would like to know if this is something that is "supported",
which I can build upon, or if the lack of verification is a JVM bug. Are
records just a Java language feature without JVM support?! I read that
final fields of records are "truly final" and can't be changed even
through reflection and assumed there must be special JVM support that
makes sure records match the Java language semantics...
Cross posting from StackOverflow:
https://stackoverflow.com/questions/73377190/bytecode-transforming-record-class-to-be-mutable
Regards,
Christian
More information about the amber-spec-comments
mailing list