About flattening a nullable j.l.Long

Quân Anh Mai anhmdq at gmail.com
Fri Nov 7 17:06:53 UTC 2025


Hi,

Thanks a lot for your answer. After thinking about it for a while, I think
it is true that this approach will not work. While it is true that a field
load must act as if it observes 1 of the concurrent stores, I forgot to
take into consideration the possibility that such store may be rendered
invalid due to a store of null happens after it. It seems that for
atomicity to hold, the store must be atomic, and there is no way around
that. How unfortunate!

Regards,
Quan Anh


On Thu, 6 Nov 2025 at 20:02, Remi Forax <forax at univ-mlv.fr> wrote:

> Hello,
> as far as i remember, the problem is that you can resurrect a value,
> for example with a Long
>
> Thread1
>   a.x = new Long(12);
>   a.x = null;
>   IO.println(a.x); //12
>
> Thread2
>   IO.println(a.x);  // null
>   a.x = new Long(77);   // descheduled in between writing the maker and
> writing the long
>
>
> The thread1 can see the Long(12) to be resurrected, something that is not
> possible with references.
>
> regards,
> Rémi
>
> ------------------------------
>
> *From: *"Quân Anh Mai" <anhmdq at gmail.com>
> *To: *"David Alayachew" <davidalayachew at gmail.com>
> *Cc: *"valhalla-dev" <valhalla-dev at openjdk.org>
> *Sent: *Thursday, November 6, 2025 3:52:41 AM
> *Subject: *Re: About flattening a nullable j.l.Long
>
> Ah yes, my bad, it is https://github.com/openjdk/valhalla/pull/1720
>
> On Thu, 6 Nov 2025 at 07:26, David Alayachew <davidalayachew at gmail.com>
> wrote:
>
>> Just a heads up, your [1] is a dead link. Can you try to put the url in
>> again?
>>
>> On Wed, Nov 5, 2025, 2:06 PM Quân Anh Mai <anhmdq at gmail.com> wrote:
>>
>>> Hi,
>>> Currently, I'm having a PR that allows flattening of a nullable
>>> value class with a 64-bit payload [1]. Dan Smith told me that some ideas
>>> along these lines were discussed a few years ago, and the consensus was
>>> that it was a dead end. May I ask what the concerns were, and whether they
>>> are still relevant now?
>>>
>>> Thanks a lot,
>>> Quan Anh
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20251108/f6d5d93a/attachment-0001.htm>


More information about the valhalla-dev mailing list