JDK-8317277 - Java language implementation of value classes and objects
Archie Cobbs
archie.cobbs at gmail.com
Wed Oct 18 21:33:45 UTC 2023
On Wed, Oct 18, 2023 at 3:59 PM Remi Forax <forax at univ-mlv.fr> wrote:
>
> 1. If v is a value object, what does System.identityHashCode(v) return?
>
>
> A combination of some field values of the object.
> It has to be fast so the VM should not use all fields if there are a lot
> of them or if some values are value class (or field type that can
> potentially store value class) because it will make the computation
> recursive.
>
Hmm, that doesn't seem right.
Isn't it hashCode()'s job to produce a value based on the object's fields?
The whole point of System.identityHashCode() is to NOT do that, at least as
of today.
I'd expect System.identityHashCode() to return 0 for all value classes or
throw an exception.
After all, value classes are not supposed to have an identity, right?
> 2. If V is a value class, is {Weak,Soft,Phantom}Reference<V> supported?
>
>
> Nope. There is maybe no address/no pointer so no weak reference.
>
OK. How is this going to be enforced?
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20231018/af395fae/attachment.htm>
More information about the valhalla-dev
mailing list