RefObject and ValObject

Brian Goetz brian.goetz at
Mon Apr 15 12:06:25 UTC 2019

> But it seems like we have already ruled this out - since, if 
> typeof(new Object()) is 'RefObject', you don't want RefObject <: Object.

I think you misunderstood the "want" here (though it still may not be 

The desired model is:
  - Object is the top type.  Everything is an Object.
  - Some objects have identity (RefObject), others do not (ValObject).  
But they are all Object.

This means we want {Ref,Val}Object <: Object.  (Whether they are 
interface or class or something else.)

One of the main reasons for wanting this setup is that it reflects the 
desired reality: everything is an object, but some are special objects 
(those with identity.)  The addition of value types is a big 
perturbation to the type system; reflecting it this way makes the object 
hierarchy reflect the reality and the desired intuition, and makes the 
distinction between ref/val slightly less magic.

(There are other reasons too; for example, wouldn't it be nice if 
ValObject.{wait,notify,notifyAll} were _ordinary final methods_ that 
threw in ValObject?  Again, slightly less magic.)

More information about the valhalla-spec-observers mailing list