Re-interpreting 'new Object()'
daniel.smith at oracle.com
Thu Sep 3 17:02:51 UTC 2020
> On Sep 3, 2020, at 8:12 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
>> API changes
>> - Add a java.lang.IdentityObject interface. The interface has no members (don't want to disrupt method resolution, etc., in any way). The javadoc, for information purposes, describes the behaviors of various Object methods.
> It's a shame this isn't the home for identityHashCode, but oh well.
The "no members" policy is a safe baseline, but I suppose we could entertain relaxing it. Adding a method to IdentityObject is about as risky as adding a method to Object—possible, but touches (almost) every class in existence, so proceed with caution.
What I had in mind was re-specifying things like Object.equals here. In a sense, it's safer than an entirely new name, but without having worked through the details, I worry about subtle changes to JVM behavior when these methods are present in the class file.
More information about the valhalla-spec-observers