<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Hi Atilla,
<div><br>
</div>
<div>If you are asking about the binary compatibility of record classes, you can read the JLS:</div>
<div><br>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div>
<div>13.4.27 Evolution of Record Classes</div>
</div>
<div>
<div><br>
</div>
</div>
<div>
<div>Adding, deleting, changing, or reordering record components in a record class may break compatibility with pre-existing binaries that are not recompiled; such a change is not recommended for widely distributed record classes.</div>
</div>
<div>
<div><br>
</div>
</div>
<div>
<div>More precisely, adding, deleting, changing, or reordering record components may change the corresponding implicit declarations of component fields and accessor methods, as well as changing the signature and implementation of the canonical constructor and
 other supporting methods, with consequences specified in Â§13.4.8 and Â§13.4.12.</div>
</div>
<div>
<div><br>
</div>
</div>
<div>
<div>In all other respects, the binary compatibility rules for record classes are identical to those for normal classes.</div>
</div>
</blockquote>
<div>
<div><br>
</div>
<div>Gavin</div>
<div><br>
<blockquote type="cite">
<div>On 25 Apr 2024, at 22:39, Attila Kelemen <attila.kelemen85@gmail.com> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div>Reading the JEP I'm unsure about some behavior when the record is recompiled with an additional component, while the code containing the `with` block is not. Can this be clarified in the JEP? Or is this undefined for now?</div>
<div><br>
</div>
<div>For better understanding, let me write down a specific example:</div>
<div><br>
</div>
<div>MyRecord.java (v1)</div>
<div>```</div>
<div>public record MyRecord(int x, int y) { }</div>
<div>```</div>
<div><br>
</div>
<div>
<div>MyRecord.java (v2)</div>
<div>```</div>
<div>public record MyRecord(int x, int y, int z) { }</div>
<div>```</div>
</div>
<div><br>
</div>
<div>
<div>MyRecord.java (v3)</div>
<div>```</div>
<div>public record MyRecord(int x, int y, int z) {</div>
<div>  public MyRecord(int x, int y) { this(x, y, 0); }</div>
<div>}</div>
<div>```</div>
</div>
<div><br>
</div>
<div>Let's suppose we have the following class which we compile against v1 of `MyRecord`, and then never recompile:</div>
<div><br>
</div>
<div>```</div>
<div>public class MyClass {</div>
<div>  public static MyRecord adjustX(MyRecord src) {</div>
<div>    return src with { x = 9; }</div>
<div>  }</div>
<div>}</div>
<div>```</div>
<div><br>
</div>
<div>Now my question is: What is the output of the following code?</div>
<div><br>
</div>
<div>```</div>
<div>System.out.println(MyClass.adjustX(new MyRecord(1, 2, 3)).z());</div>
<div>```</div>
<div><br>
</div>
<div>A, When running with v2 of `MyRecord` on the classpath</div>
<div>B, When running with v3 of `MyRecord` on the classpath.<br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Attila</div>
<div><br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>