<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">This was received on the
-comments list.<br>
<br>
This is definitely an abuse, which may have been done out of
ignorance (transform all the classes, without looking very
carefully) or out of cleverness-toxicity (many people's judgment
gets turned off when they think they're being clever.) But
generating "mutable records" is a serious party foul, and we
should treat it the way normal communities treat party fouls --
with shame (and if that doesn't work, banishment.) <br>
<br>
The JVM has some awareness of record-ness (e.g., the Record
attribute, primarily used to support reflection), but like with
so many features, the JVM can't enforce every requirement that
the language enforces (and often shouldn't.) <br>
<br>
Most ORMs have figured out how to work with immutable carriers.
The EBean community should be encouraged to do the same, or to
not try to work with records. These attempts to "rewrite rules
you don't like" may offer the author a brief frisson of
perceived "sticking it to the man", but ultimately just pollute
the community, to everyone's detriment. <br>
</font></font>
<div class="moz-forward-container"><br>
<br>
-------- Forwarded Message --------
<table class="moz-email-headers-table" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Subject:
</th>
<td>Bytecode transforming record class to be mutable</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Date: </th>
<td>Wed, 17 Aug 2022 16:50:09 +0200</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">From: </th>
<td>Christian Beikov <a class="moz-txt-link-rfc2396E" href="mailto:christian.beikov@gmail.com"><christian.beikov@gmail.com></a></td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">To: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:amber-spec-comments@openjdk.org">amber-spec-comments@openjdk.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
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.<br>
<br>
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:<br>
<br>
* Make fields for record components non-final<br>
* Add additional fields that are not set through the canonical
constructor, nor exposed through record component attributes<br>
<br>
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...<br>
<br>
Cross posting from StackOverflow:
<a class="moz-txt-link-freetext" href="https://stackoverflow.com/questions/73377190/bytecode-transforming-record-class-to-be-mutable">https://stackoverflow.com/questions/73377190/bytecode-transforming-record-class-to-be-mutable</a><br>
<br>
Regards,<br>
<br>
Christian<br>
<br>
</div>
</body>
</html>