RFR 8173083: VarHandle usages in LockSupport and ThreadLocalRandom result in circularity issues

Martin Buchholz martinrb at google.com
Fri Jan 20 17:45:49 UTC 2017


On Fri, Jan 20, 2017 at 7:58 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

>
> I was surprised to see below a change in parentheses that seems to change
> the behavior.
>
>      final long nextSeed() {
>          Thread t; long r; // read and update per-thread seed
> -        SEED.set(t = Thread.currentThread(),
> -                 (r = (long) SEED.get(t)) + GAMMA);
> +        U.putLong(t = Thread.currentThread(), SEED,
> +                  r = U.getLong(t, SEED) + GAMMA);
>          return r;
>      }
>
>
> The update reverted to the previous code:
>
> http://hg.openjdk.java.net/jdk9/dev/jdk/file/7901a13a051c/src/java.base/
> share/classes/java/util/concurrent/ThreadLocalRandom.java
>
> I added the parentheses to bound the cast.
>

It still looks to me like the parenthesis got added to the wrong place (in
the previous changeset!), changing the behavior, and the current reverted
code is correct.


More information about the core-libs-dev mailing list