JDK 9 RFR of JDK-8035279: Clean up internal deprecations in BigInteger

David Holmes david.holmes at oracle.com
Thu Feb 27 10:07:29 UTC 2014

On 26/02/2014 10:56 PM, Peter Levart wrote:
> On 02/25/2014 09:38 PM, Brian Burkhalter wrote:
>> On Feb 20, 2014, at 1:42 AM, Paul Sandoz wrote:
>>> Not sure the static powerCache field, in the original code, needs to
>>> be volatile either:
>>> 1137     private static volatile BigInteger[][] powerCache;
>> Is there consensus on whether "volatile" is necessary here?
> I think it has to be volatile. The powerCache implementation was added
> in the following changeset:

Definitely has to be volatile for current code. I don't know what I was 
looking at when I said it didn't need to be - I didn't see the code that 
grows the cache. <shakes head in dismay>


>      http://hg.openjdk.java.net/jdk9/dev/jdk/rev/7546
> ...and improved later in the following:
>      http://hg.openjdk.java.net/jdk9/dev/jdk/rev/7586
> It uses a copy-on-write technique to extend the cache with new values
> when needed. volatile is mandatory here to safely publish the newly
> constructed array-of-arrays and the newly constructed sub-array to other
> threads. Without volatile, other threads could see null slots where
> BigInteger[] and/or BigInteger objects should be...
> Regards, Peter
>> Thanks,
>> Brian

More information about the core-libs-dev mailing list