Objects.newIdentity update

Brian Goetz brian.goetz at oracle.com
Mon Jul 19 18:53:00 UTC 2021

I understand your frustration, but the claims you make here in defense 
of "identity" are not right.  Value-based classes can (and currently do) 
have identity; VBC means that it is a mistake to _depend_ on that 
identity.  (Same as with Integer boxes.) Similarly, lambdas may have 
identity, but the system makes no guarantees about the identity of the 
object that results from evaluating a lambda expression.

> Not all objects have an identity, we have already introduced value based class
> https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/doc-files/ValueBased.html
> a long time ago.
> The JLS also says that lambdas have no identity.
> First, i believe there is a problem of communication somewhere, the fact that newIdentity() returns new Object() is not important,
> we all now, and this is especially true for people dealing with the core libraries that implementations change.
> In a sense, it's normal to have a discussion about what identity means and Object being the root of everything, because introducing Objects.newIdentity() is a move to make current developers more aware of that. We have started that discussion with the introduction of value based class, more recently with JEP 390, Objects.newIdentity() is just the continuation of the logic of delivering features in pieces.
> With that in mind, not adding Objects.newIdentity() now seems shortsighted.
> Rémi
> [1] https://openjdk.java.net/jeps/390

More information about the valhalla-spec-observers mailing list