where are all the objects?

Brian Goetz brian.goetz at oracle.com
Thu Aug 11 20:08:39 UTC 2022


We may be circling around the terminology block, but let's try on not 
calling an int or a Point "a value" without some sort of modifier.

Let's try "value object" rather than just "value"; a variable of type 
int or Point.val holds a value object, and Point.ref holds a *reference 
to a* value object.  Object holds references to either value or identity 
objects.  Primitives are revealed to be value objects.  Everything is an 
object.

(Alternately, we could lean on more placement-centric terminology.  
Point.val and int are _direct values_ (or immediate values).  But what 
do we say about references then? References are references to objects.  
This one feels like it recedes more into the mental models we don't want 
to encourage.)

So:

  - classes have instances, which are objects
  - some classes are identity classes and some are value classes
    - instances of identity classes have identity, are called identity 
objects
    - instances of value classes have no identity, are called value objects
  - any objects can be the target of an object reference
    - Polymorphic types like Object or Runnable may refer to identity or 
value objects
  - value objects can be represented/stored/manipulated directly as 
well, like our old friend int
  - legacy primitive are value objects now!
    - everything is an object
  - The type P.ref is a reference type, it consists of references to 
instances of P
  - The type P.val is a value type, it consists of instances of P, which 
are value objects
  - Integer is a reference type, int is a value type

This isn't much different from the previous "VAO" presentation, other 
than being more explicit about saying "value objects" rather than just 
values -- does that help at all?






On 8/10/2022 3:34 PM, Brian Goetz wrote:
>>
>> Does the VAO model feel less forced if we're explicit about 
>> references being the difference?
>>  - A value object can also be represented without an object 
>> reference, as primitives are today   // (*)
>>
>
> This is actually the new weirdness -- that you have a choice about how 
> to handle a value object.  Previously we had two kinds of things: 
> primitives (direct values) and object references (which can be null, 
> or can have an object at the end of them, but you can't touch the 
> object, only the reference.)  Now we still have two kinds of values: 
> value objects, and object references -- but object references can also 
> refer to value objects!  This is the weird part; that value objects 
> have two separate placements / representations / interaction modes.  
> We got away before without a notion of "bare object" because the only 
> way you could touch a primitive is directly, and the only way you 
> could touch an object is through a reference.  But now some objects 
> can be touched directly, *or* through a reference. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-observers/attachments/20220811/0619808f/attachment.htm>


More information about the valhalla-spec-observers mailing list