Proposal for Decimal64 and Decimal128 value-based classes
maurizio.cimadamore at oracle.com
Thu Apr 1 09:35:55 UTC 2021
On 31/03/2021 23:54, Dan Smith wrote:
>> On Mar 31, 2021, at 3:27 PM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>> What I'd be curious though, is if the @ValueBased annotation could be enhanced to say _which_ primitive class default you want (and then javac could enforce extra checks if you pick the "val" default). If something like this was feasible (cc'ing Dan), maybe some of the friction here could be removed?
> You mean annotate a class with "pretend this class's name represents a value type" and then implement the associated null checks in javac, even though we don't actually have value types yet?
> I'd expect that to run into a number of problems related to the fact that the language model hasn't actually been updated to include primitive classes or value types yet. Plus the lack of features like reference types (Foo.ref) would be limiting for programmers who need them. Plus binary incompatibility—value types need special encoding in class files, and those class files aren't legal yet; when they are, you risk mismatches.
> In this case I think the straightforward approach of just completing and delivering the Valhalla features is better than trying to spin off a small taste of them early.
You are right - there are more aspects to this than just null checks -
binary compatibility seems especially problematic.
Thanks for the explanation!
More information about the core-libs-dev