Make new Object() backward compatible

Brian Goetz brian.goetz at oracle.com
Sun May 9 15:04:31 UTC 2021



> The logical conclusion is that java.lang.Object is a parametric class with a parameter saying if it should implement IdentityObject or not.

Magic hammer, meet nail :)

To be explicit, what you're suggesting is something like

     class Object<ID : boolean> { ... }

where an identity class extends Object<true> and a primitive class 
extends Object<false> (and most interfaces remain parametric in ID.)

Its conceptually elegant, and we've discussed it before; in theory 
parametricity could range over things other than types, such as 
constants, identity-ness, etc (e.g., the ref and val projections could 
be species).  But to apply it to a problem as prosaic as this seems like 
cracking a walnut with a two-ton bomb.  (I don't thing this is what you 
want to teach on day 1.)




More information about the valhalla-spec-experts mailing list