About flattening a nullable j.l.Long

Frederic Parain frederic.parain at oracle.com
Fri Nov 7 15:13:16 UTC 2025


Here's a write-up from John Rose on this subject:

https://cr.openjdk.org/~jrose/values/NullabilityRequiresConsistency.java.txt

Fred


On 11/7/25 05:39, Tobias Hartmann wrote:
> Right, the example provided by Rémi shows the issue. The null marker 
> needs to be written atomically with the payload.
>
> Best regards,
> Tobias
>
>
> On 11/6/25 2:02 PM, Remi Forax 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 
>> <https://github.com/openjdk/valhalla/pull/1720>
>>
>>     On Thu, 6 Nov 2025 at 07:26, David Alayachew 
>> <davidalayachew at gmail.com <mailto: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 
>> <mailto: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
>>
>>
>


More information about the valhalla-dev mailing list