RFR: 8209120: Archive the Integer.IntegerCache
Peter Levart
peter.levart at gmail.com
Thu Aug 9 16:38:56 UTC 2018
On 08/09/2018 06:28 PM, Claes Redestad wrote:
>
>
> On 2018-08-09 17:41, Peter Levart wrote:
>>
>> There's danger when you overwrite a non-null @Stable field with
>> another value that this new value will not be seen. Or is <clinit>
>> code an exception where @Stable is not honored yet...
>
> Typically IntegerCache::<clinit> runs before JIT has even started, so
> I think we're OK even though the double-assignment is undefined. But
> it's a good question what happens in cases we're running AOTd code, so
> perhaps this pattern might be problematic in some future..
What if you run it with -Xcomp ? Would still be run by interpreter at
startup?
Regards, Peter
>>
>> To mitigate this possibility, you could have two fields:
>>
>> static Integer cache[];
>> static final Integer finalCache[];
>>
>> The 'cache' field is archived and de-archived. The final result is
>> set to 'cache' by overwriting and to 'finalCache'. The later is then
>> also used in Integer.valueOf().
>
> Right, this would be a cheap way to dispel any concerns here.
>
> /Claes
>
More information about the core-libs-dev
mailing list