Recursively comparing

John Bossons jbossons at gmail.com
Wed Feb 28 00:04:03 UTC 2024


Hi Remy,

Even for a value object field in which the stored VO value is a reference?

As I understand the spec, it's up to the JVM to choose how to handle a
value object (even a null-restricted VO), depending on its size. If a VO
field value is a VO, it's optional as to whether the JVM stores that field
value as a reference or as a value. What the JVM does will depend on the VO
size, right? If a VO field value is stored as a reference, calling == on
that reference will behave the same way as calling == on an identity object
reference. If the VO is stored as a value (a set of values which could
include another VO. field), then the == will be recursive. Am I incorrect?

John

On Tue, Feb 27, 2024 at 3:03 PM <forax at univ-mlv.fr> wrote:

>
>
> ------------------------------
>
> *From: *"John Bossons" <jbossons at gmail.com>
> *To: *"Archie Cobbs" <archie.cobbs at gmail.com>
> *Cc: *"Remi Forax" <forax at univ-mlv.fr>, "Pedro Lamarão" <
> pedro.lamarao at prodist.com.br>, "valhalla-dev" <valhalla-dev at openjdk.org>
> *Sent: *Tuesday, February 27, 2024 8:36:13 PM
> *Subject: *Re: Recursively comparing
>
> Yes, but 'deep' only for (small) value objects that are stored by value.
>
>
> No, the semantics of a value class instance is independant of the storage,
> calling == on a value object always behave the same way.
>
> Rémi
>
>
> On Tue, Feb 27, 2024 at 12:09 PM Archie Cobbs <archie.cobbs at gmail.com>
> wrote:
>
>> On Tue, Feb 27, 2024 at 10:48 AM John Bossons <jbossons at gmail.com> wrote:
>>
>>> Where the set of field values stored for a value object field contains a
>>> field that is in turn a value object, this recursive definition would imply
>>> a recursive application of == to the set of field values stored for that
>>> object, would it not? Which sounds awfully close to a deep equals test for
>>> value object fields (but not identity fields).
>>>
>>
>> That's a good point... so a simple (for Java developers) way to explain
>> the behavior might be: "Deep equals" for value objects and "== equals" for
>> non-value objects.
>>
>> -Archie
>>
>> --
>> Archie L. Cobbs
>>
>
>
> --
> Phone:  (416) 450-3584 (cell)
>
>

-- 
Phone:  (416) 450-3584 (cell)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20240227/397543fc/attachment.htm>


More information about the valhalla-dev mailing list