Objects.newIdentity update

Remi Forax forax at univ-mlv.fr
Mon Jul 19 18:45:46 UTC 2021


----- Original Message -----
> From: "daniel smith" <daniel.smith at oracle.com>
> To: "valhalla-spec-experts" <valhalla-spec-experts at openjdk.java.net>
> Cc: "Roger Riggs" <roger.riggs at oracle.com>
> Sent: Lundi 19 Juillet 2021 19:59:03
> Subject: Objects.newIdentity update

[I've added Mark in CC]

> An update on Objects.newIdentity for Java 17: Roger did some work to put the
> feature together and get it reviewed.
> 
> https://bugs.openjdk.java.net/browse/JDK-8269096
> 
> However, while the implementation is straightforward, for libraries folks not
> deeply familiar with the Valhalla Project, the concept of a method that does
> the same thing as 'new Object()' did not seem particularly justified. I think
> they're especially uncomfortable with the idea of talking about creating an
> "identity" in a world in which all objects have identity.
> 
> https://bugs.openjdk.java.net/browse/JDK-8269097

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