Skip to content

Commit

Permalink
8290079: Reduce interaction with volatile in static initializer of Bi…
Browse files Browse the repository at this point in the history
…gInteger

Reviewed-by: jpai, rriggs, darcy
  • Loading branch information
stsypanov authored and jddarcy committed Jul 13, 2022
1 parent 74ac5df commit c83fcbd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/java.base/share/classes/java/math/BigInteger.java
Expand Up @@ -1273,13 +1273,14 @@ private static BigInteger valueOf(int[] val) {
* with just the very first value. Additional values will be created
* on demand.
*/
powerCache = new BigInteger[Character.MAX_RADIX+1][];
BigInteger[][] cache = new BigInteger[Character.MAX_RADIX+1][];
logCache = new double[Character.MAX_RADIX+1];

for (int i=Character.MIN_RADIX; i <= Character.MAX_RADIX; i++) {
powerCache[i] = new BigInteger[] { BigInteger.valueOf(i) };
cache[i] = new BigInteger[] { BigInteger.valueOf(i) };
logCache[i] = Math.log(i);
}
BigInteger.powerCache = cache;
}

/**
Expand Down

1 comment on commit c83fcbd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.