Alternative to the suffix .val and .ref in JEP 401: Primitive Objects

Anderson Vasconcelos Pires andvasp at
Thu May 13 01:25:25 UTC 2021

Thank you Remi and Brian!

Understood. val / ref makes the concept clearer.

Is the 401/402 JEPs available for testing in the valhalla repository?


On Wed, May 12, 2021 at 11:09 AM Brian Goetz <brian.goetz at> wrote:

> On 5/11/2021 10:51 PM, Anderson Vasconcelos Pires wrote:
> > Hi guys,
> >
> > I saw Michael Kuhlmann's e-mail [1] where he quotes:
> >
> > "The suffixes .ref and .val don't fit into our concept of class names,
> they
> > look ugly and can easily be mixed up."
> >
> > I have no complaints about them. But I believe it would be better, *if
> > possible*, not to use them.
> I know this isn't what you meant, but it is definitely better not to use
> them if they can be avoided!  The design of the feature works hard to
> minimize the cases where someone actually has to say .ref or .val; these
> are escape hatches that most users should not use regularly.
> > I believe it would be better to use the operator "?" instead of .ref.
> > because it can be used when the "null safety" feature comes to Java. :)
> We have discussed this extensively, but the reasons you cite are exactly
> why we *cannot* use `?` here, and that is -- because it means something
> else.  Ref/val refer to how the object is stored (flat vs indirect), not
> to its value set.  But by calling it `Foo?`, it would be almost
> impossible for users to see this as anything other than non-nullable
> Foo.  But identity classes, such as ArrayList, cannot be flattened (they
> need their identity for mutation), and yet the notion of "non-nullable
> reference to ArrayList" makes perfect sense.  So while `?` and `ref`
> seem to have a lot in common, they are not the same thing, and trying to
> pun them together would only be confusing.

More information about the valhalla-dev mailing list