<div dir="ltr">Good question. The latest valhalla spec is as non-invasive as possible: we are still passing a value representing the reference pointer to an immutable value object, which is identical to a copy of the values. This will be the case for JEP 401, Value Objects.<div><br></div><div>Ideally, we want the reference to where the values are in memory to be usable, given this is the most memory-efficient representation. This is largely equivalent to a copy of the values given value objects are immutable, except they are different when a value object is stored in a mutable field in an identity object. In such cases, we may observe a "tear" when we read the reference to the memory location, meaning we can observe a value object that was composed from the result of different writes due to instruction reordering and CPU caches.</div><div><br></div><div>We currently prototype to allow such inconsistency to happen by declaring a value object as "loosely consistent", so all value object instance in the cartesian product of all legal individual field values are all legal and expected by programs.</div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Oct 19, 2025 at 7:51 PM david Grajales <<a href="mailto:david.1993grajales@gmail.com">david.1993grajales@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Java always passes by value. When someone passes a primitive to a method it passes a copy of the value of the primitive, when one pass a reference type what is really being passed it's a copy of the "value" of the object (just happens to be the value of an object is its reference) <div><br></div><div>When a value object (let's say a value record) is being passed to a method, does it pass a copy of the values or a reference to where the values are in memory?</div></div>
</blockquote></div>