Making Object abstract
John Rose
john.r.rose at oracle.com
Wed Jun 16 21:50:35 UTC 2021
On Jun 2, 2021, at 7:57 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
>
> A minor bikeshed comment: We're asking users to change their `new Object()` to `IdentityObject.newIdentity()`, and they may ask "why do I have to say 'Identity' twice"? (And by ask, I mean grumble, because we're already asking them to change their working code.)
>
> After a few minutes of thought, I think it might be a better fit to put this at Objects::newIdentity. The methods in Objects are conveniences that users could write themselves, which this basically is -- there's nothing special about this method, other than having a preferred alternative to `new Object()` which users will understand. So parking this where the Object conveniences go seems slightly lower friction.
I think this is OK.
As a stretch move, I think we can even retro-upgrade
the type checking of Objects::newIdentity with type
variable trickery, when IdentityObject becomes real.
Please see:
https://bugs.openjdk.java.net/secure/attachment/95170/Foo.java
https://bugs.openjdk.java.net/browse/JDK-8268919
— John
More information about the valhalla-spec-observers
mailing list