On Tue, 24 Mar 2026 16:25:51 GMT, Stefan Karlsson <[email protected]> wrote:

>> src/hotspot/share/prims/unsafe.cpp line 258:
>> 
>>> 256:   void put(T x) {
>>> 257:     GuardUnsafeAccess guard(_thread);
>>> 258:     assert(_obj == nullptr || !_obj->is_inline_type(), "must be an 
>>> object instance");
>> 
>> The message of the assert seems to date from the ancient times when value 
>> types were not subclasses of j.l.Object. A more accurate message today would 
>> be "must be an object with identity". This applies to the assert at line 312 
>> too.
>
> OK. I've updated the comments to what you suggested. I'm still a little bit 
> hesitant a about that formulation, it now sounds like there's an important 
> property that the object has an identity, but I don't think that's why the 
> assert is there. Isn't it more that we shouldn't be calling this function 
> with value objects?

The important point is more immutability than identity. Instances of value 
classes are immutable by definition. Identity objects can be mutable. What 
about "object must be mutable" instead?
Or more precise: "receiver cannot be an instance of a value class because they 
are immutable"?

-------------

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2258#discussion_r2982856186

Reply via email to