RFR: 8292877: java/util/concurrent/atomic/Serial.java uses {Double,Long}Accumulator incorrectly

Aleksey Shipilev shade at openjdk.org
Wed Aug 24 18:23:17 UTC 2022


[JDK-8026344](https://bugs.openjdk.org/browse/JDK-8026344) added tests that subtly contradict the contract for `{Double,Long}Accumulator`-s, which breaks the tests on some platforms even in the single-threaded case.

They use accumulators with binary plus as update function and using non-zero values as identity, which breaks once accumulators create many cells, reset their values to identity, and then apply the function over them, producing unexpected values.

See the investigation on RISC-V here:
  https://mail.openjdk.org/pipermail/riscv-port-dev/2022-August/000594.html

We can do what `DoubleAccumulator` javadocs do as the sample, namely: "For example, to maintain a running maximum value, you could supply Double::max along with Double.NEGATIVE_INFINITY as the identity."

Additional testing:
 - [x] Linux x86_64, `java/util/concurrent` tests

-------------

Commit messages:
 - Fix

Changes: https://git.openjdk.org/jdk/pull/10002/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10002&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8292877
  Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/10002.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/10002/head:pull/10002

PR: https://git.openjdk.org/jdk/pull/10002


More information about the core-libs-dev mailing list