RFR 8160710: Enable Thread to grant VarHandle field access to ThreadLocalRandom/Striped64

Paul Sandoz paul.sandoz at oracle.com
Wed Jan 11 20:21:49 UTC 2017


Hi,

Please review:

  http://cr.openjdk.java.net/~psandoz/jdk9/8160710-thread-to-tlr/webrev/

This patch updates ThreadLocalRandom, Striped64 and LockSupport to use VarHandles instead of Unsafe to access fields in Thread, via the MethodsHandles.privateLookupIn method.

Since there are three usages of MethodsHandles.privateLookupIn in ThreadLocalRandom i consolidated the doPrivileged block in a private static helper method, being paranoid i placed some checks to avoid this method being potentially abused to circumvent the security check, perhaps that is overkill?

I ran this patch though our test infra a few times and have not observed any transient failures.

Thanks,
Paul.


More information about the core-libs-dev mailing list