<div dir="auto"><div>To answer your question specifically Rémi, I figured this would be useful to prevent things like misuse. For example, the JEP shows how BigInteger can't be a value class due to its internal use of mutability. Well, something like enforcing value classes might have prevented that. Or maybe not, I am ignorant about that example specifically.</div><div dir="auto"><br></div><div dir="auto">But hopefully you see my point? It feels like there a lot of validation opportunities being left on the table. Value classes aren't just faster, they are safer. So, being able to assert that safety for all child classes seems nice.</div><div dir="auto"><br></div><div dir="auto">Or maybe I am wrong, and Value classes aren't inherently safer. Finality feels safe to me, and finality by default feels safer. Idk.</div><div dir="auto"><br></div><div dir="auto">Truthfully, I'm operating more on feelings here than genuine experience. I'll have something more concrete (or see where I'm wrong) to say once the new EA comes out.<br><br><div class="gmail_quote gmail_quote_container" dir="auto"><div dir="ltr" class="gmail_attr">On Tue, Sep 23, 2025, 8:31 AM Remi Forax <<a href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#000000"><div><br></div><div><br></div><hr id="m_2063411757691996670zwchr"><div><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From: </b>"David Alayachew" <<a href="mailto:davidalayachew@gmail.com" target="_blank" rel="noreferrer">davidalayachew@gmail.com</a>><br><b>To: </b>"valhalla-dev" <<a href="mailto:valhalla-dev@openjdk.java.net" target="_blank" rel="noreferrer">valhalla-dev@openjdk.java.net</a>><br><b>Sent: </b>Tuesday, September 23, 2025 2:19:40 PM<br><b>Subject: </b>Question about Value Classes and inheritance<br></blockquote></div><div><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="auto">Hello <span class="gmail_chip gmail_plusreply" dir="auto"><a href="mailto:valhalla-dev@openjdk.java.net" style="color:#15c;text-decoration:underline" target="_blank" rel="noreferrer">@valhalla-dev</a></span>,<div dir="auto"><br></div><div dir="auto">I read through JEP 401, and the subsection about subtyping surprised me.</div><div dir="auto"><br></div><div dir="auto">It appears that Abstract Value Classes can permit both Value child classes and Identity child classes. The example of BigInteger helps explain why.</div><div dir="auto"><br></div><div dir="auto">Ok, but there doesn't seem to be any way to say "only value classes can extend me!"</div><div dir="auto"><br></div><div dir="auto">Why is that?</div><div dir="auto"><br></div><div dir="auto">And to be clear, I am not bothered by Abstract Value Classes permitting Identity children, that's fine.</div></div></blockquote><div><br></div><div>I'm glad this is fine by you because it's important for backward compatibility, it means that you can declare an existing abstract class has "value enable", without requiring sub-classes to be changed.</div><div><br></div><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="auto"><div dir="auto"> I'm moreso confused by lack of ability to say "only value children".</div></div></blockquote><div><br></div><div>Declaring a class has a value class is really close to be an implementation detail (it mainly depends on if your code abuse of == or not),</div><div>so why do you want such ability ?</div><div><br></div><div><br></div><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="auto"><div dir="auto"><br></div><div dir="auto">Thank you for your time and consideration.</div><div dir="auto">David Alayachew</div></div></blockquote><div><br></div><div>regards,</div><div>Rémi</div><div><br></div></div></div></div></blockquote></div></div></div>