[External] : Re: Consolidating the user model

Brian Goetz brian.goetz at oracle.com
Thu Nov 4 15:54:08 UTC 2021


To close the loop, in the initial "Eclair" discussion (which grew out of 
a conversation at the last JVMLS), a primitive was a pair of classes, 
where the companion class was actually an interface.  We haven't 
revisited "what is Point.ref" since then, but one possible way to do 
this is to say exactly this: that Point is a primitive class, and 
Point.ref is an interface it implements.  That makes it clear that (a) 
why it is a reference type, (b) that it is no different from other 
superinterfaces, and (c) that no object is actually of type Point.ref.

Q1: does this help?

Q2: Does this provide us a path to rehabilitating the user intuition 
around boxing, by saying "good news everyone, we still have boxes, but 
now they're interfaces, not concrete objects."  Does that balance the 
desire to lean on existing intuition, while breaking enough about the 
implementation assumptions to not carry all the existing baggage?


>
> In the new world, Point.ref is like Comparable; it exists as a static 
> type for variables, but there are no objects that are *instances* of 
> Point.ref, because its not a concrete type.
>
>     Point p = new Point(3, 4);
>     Point.ref asRef = p;
>
> This is like the String to Comparable example; the new variable refers 
> to the same object, but through an alias that has a different static 
> type.



More information about the valhalla-spec-observers mailing list