<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4" face="monospace">The below was received on
amber-spec-comments. <br>
<br>
The author makes a renewed plea for final, non-component fields in
records. <br>
<br>
This point was discussed extensively during the design of records,
so I won't recapitulate the discussion here. </font>
<div class="moz-forward-container"><br>
<br>
-------- Forwarded Message --------
<table cellpadding="0" cellspacing="0" border="0" class="moz-email-headers-table">
<tbody>
<tr>
<th valign="BASELINE" align="RIGHT" nowrap="nowrap">Subject:
</th>
<td>An improvement request on records</td>
</tr>
<tr>
<th valign="BASELINE" align="RIGHT" nowrap="nowrap">Date: </th>
<td>Thu, 11 Dec 2025 15:27:28 +0100</td>
</tr>
<tr>
<th valign="BASELINE" align="RIGHT" nowrap="nowrap">From: </th>
<td>Kai Hofmann <a class="moz-txt-link-rfc2396E" href="mailto:java@kai-hofmann.de"><java@kai-hofmann.de></a></td>
</tr>
<tr>
<th valign="BASELINE" align="RIGHT" nowrap="nowrap">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>
To whom it may concern,<br>
<br>
I am working here since some years on my OpenSource projects, and
until now I had never a reason to made comments on Java - but now
I feel I have to raise my voice on records:<br>
<br>
<br>
Since some years I developed a library of DDD valueObjects both as
normal Java objects and also in a parallel branch as records. At
the moment you can find this work here:<br>
<br>
<a class="moz-txt-link-freetext" href="https://github.com/PowerStat/Validation">https://github.com/PowerStat/Validation</a><br>
<br>
But I plan to rename this project, because in the meantime the
project name is no longer a good choice - maybe it will name
something like ValueObjectLibrary - you will find it under my
github repos.<br>
<br>
<br>
So from my experiences I can say it is a correct design decision
to not have instance fields within records.<br>
<br>
But in my opinion this thought is to simple, because private
"final" instance fields should be possible and will be useful and
could safe duplicated code as well as runtime!<br>
<br>
So the point is that final instance fields have to be initialized
within the constructor and will be unchangeable after a record has
been constructed - so they are harmless!<br>
<br>
As an example I have implemented a MACAddress class/record that
represents a hardware mac address.<br>
<br>
Within the normal class implementation I split the mac address
into it's parts only once within the construtor, later on I have
multiple methods that work on this split parts.<br>
<br>
But within a record this is not possible so I have to do the split
within every method where I need it - thats waste of code and
runtime!<br>
<br>
Another example is my implementation of the ISBN13 - see
<a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/ISBN">https://en.wikipedia.org/wiki/ISBN</a><br>
<br>
These numbers could come with 2 different formats: with or without
separator chars in it - both formats are equal.<br>
<br>
So in my class implementation I would do a normalization (without
separators) and store this one internally.<br>
<br>
Within a record this normalization in the construtor is not
possible, because I could not have instance fields nor could I
change the records parameter within the constructor because its
already fixed :(<br>
<br>
So ISBN13 could not be implemented as a record!<br>
<br>
I vote for extending the record specification to have private
"final" instances within it and maybe to allow to manipulate the
construction parameters within the constructor.<br>
<br>
Would be nice to hear from you about this.<br>
<br>
<br>
Greetings and have a nice Christmas and a Happy New Year.<br>
<br>
<br>
PowerStat (Kai Hofmann)<br>
<br>
<br>
</div>
</body>
</html>