RFR (S) 8150465: Unsafe methods to produce uninitialized arrays

Andrew Haley aph at redhat.com
Wed Mar 2 08:45:30 UTC 2016


On 01/03/16 23:34, Jim Graham wrote:
> Thanks Paul,
> 
> That code doesn't seem to follow the recommendations in the new 
> allocateUninit() method as far as publicizing the address field.  Unless 
> unsafe.setMemory() does a fence?

DirectByteBuffer.cleaner is final, so there is a fence at the end of
DirectByteBuffer's constructor.  But there is perhaps a race here
because a Deallocator instance is created before the
Unsafe.setMemory() becomes observable to the cleaner thread.  I don't
think that matters as long as the Deallocator is sane, but it's not a
pattern I like much.

Andrew.


More information about the jdk9-dev mailing list