> From: "David Alayachew" <[email protected]> > To: "valhalla-dev" <[email protected]> > Sent: Tuesday, September 23, 2025 2:19:40 PM > Subject: Question about Value Classes and inheritance
> Hello [ mailto:[email protected] | @valhalla-dev ] , > I read through JEP 401, and the subsection about subtyping surprised me. > It appears that Abstract Value Classes can permit both Value child classes and > Identity child classes. The example of BigInteger helps explain why. > Ok, but there doesn't seem to be any way to say "only value classes can extend > me!" > Why is that? > And to be clear, I am not bothered by Abstract Value Classes permitting > Identity > children, that's fine. 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. > I'm moreso confused by lack of ability to say "only value children". 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), so why do you want such ability ? > Thank you for your time and consideration. > David Alayachew regards, Rémi
