Fwd: valhalla-spec-comments post from jackammo77 at gmail.com requires approval

Brian Goetz brian.goetz at oracle.com
Tue Feb 19 22:46:14 UTC 2019


This was received on (and got stuck in the filter of) the -comments list.

> Subject: Migrating the primitive boxes to values
> From: Jack Ammo <jackammo77 at gmail.com>
>
> From an outsider's perspective, i'd like to ask a perhaps naive 
> question about the locking issue on values. Instead of just opting to 
> break existing code as you seem to be worried about, why not just box 
> the value before locking? Assuming that a boxing conversion to a full 
> fledged Object is still kicking around as a fall back, this seems like 
> the most familiar option to me as a developer: i can technically do 
> the lock on an Integer but it is not advised and results are not 
> guaranteed. I understand that everyone has worked hard to avoid the 
> cost of boxing, but in this particular case it seems like a decent 
> option that is the least difficult to wrap my mind around. Locking 
> requires a full Object, so values (like an int) need to be boxed as such.

This is not a naive question, but there is a simple answer: because in 
L-World, there are no boxes any more!

In our previous attempt, Q-world, value types were like primitives; they 
each had a box companion type, which was a full-blown box.  But in 
L-world, values are subtypes of Object, and there is no corresponding 
box object (because the whole point of boxes is so we can interoperate 
with Object, and there's no need to do so if values are subtypes of 
Object.)  We still keep the distinction between L- and Q- value types, 
but the distinction now means only whether null is included in the value 
set or not. Both are still subtypes of Object and use the L carrier.  
(Think of QFoo as a restriction type on LFoo, which means "non-null.")

So what you're suggesting amounts to: inflate an interned proxy object 
and lock on that.  Which is surely doable, but is no longer a "just use 
the box", since there is no box to "just" use.

Cheers,
-Brian


More information about the valhalla-dev mailing list