RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Apr 4 10:03:34 UTC 2016

On 04/03/2016 03:51 AM, Claes Redestad wrote:
> BufferedInputStream is loaded early, and uses 
> AtomicReferenceFieldUpdater to provide CAS functionality to allow for
> closing streams asynchronously. Using Unsafe directly instead does
> the exact same thing in the end, but avoids loading a few (4) classes
> and thus brings us a small startup improvement.

> Bug: https://bugs.openjdk.java.net/browse/JDK-8153334
> Webrev: http://cr.openjdk.java.net/~redestad/8153334/webrev.01/

I think this one is going too far.

A*FU/VarHandles should are supposed to act like a go-to replacement for
Unsafe throughout the class library, and we want to shrink the Unsafe
exposure. Also, I don't think removing A*FU in favor of Unsafe here wins
us anything: there should be no throughput hit, and we *will* load A*FU
down the road anyway, negating the startup wins.


More information about the core-libs-dev mailing list