JDK 9 RFR of JDK-8035279: Clean up internal deprecations in BigInteger
brian.burkhalter at oracle.com
Wed Feb 26 19:51:17 UTC 2014
On Feb 26, 2014, at 4:56 AM, Peter Levart 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:
> ...and improved later in the following:
> 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...
Thanks for the clarification, Peter.
More information about the core-libs-dev