RFR : 8185362: Replace use of AtomicReferenceFieldUpdater from BufferedInputStream with Unsafe
peter.levart at gmail.com
Mon Aug 21 14:47:03 UTC 2017
On 08/21/2017 01:15 PM, Claes Redestad wrote:
> On 08/21/2017 12:29 PM, Aleksey Shipilev wrote:
>> On 08/21/2017 12:20 PM, Claes Redestad wrote:
>>> Webrev: http://cr.openjdk.java.net/~redestad/8185362/jdk.00/
>> *) Should be static *final*, otherwise you miss constant folding for
>> Unsafe accesses:
>> 66 private static long BUF_OFFSET =
>> U.objectFieldOffset(BufferedInputStream.class, "buf");
>> *) While you are at it, maybe switch to proper Java style here, e.g.
>> "volatile byte buf"?
>> 73 protected volatile byte buf;
> Done: http://cr.openjdk.java.net/~redestad/8185362/jdk.01/
Just a side question...
Is BufferedInputStream.close() intentionally not synchronized? All other
methods are. If close() was synchronized too, no CAS would be needed and
fields could be normal, not volatile. What is achieved by close() not
being synchronized? Fear of deadlocks?
More information about the core-libs-dev