[concurrency-interest] DirectByteBuffers and reachabilityFence

David Holmes davidcholmes at aapt.net.au
Wed Dec 9 06:11:06 EST 2015

Andrew Haley writes:
> On 09/12/15 09:21, David Holmes wrote:
> > The happens-before requirement was deliberately set the way it is to
> > show that an object can not be finalized before its construction has
> > completed (whether normally or abnormally). So I would agree with
> > Justin that it should not be possible for an object to be finalized
> > before construction has completed - regardless of potential compiler
> > optimizations etc.
> Hmmm, okay.  It might be that I misremembered or perhaps it was a bug,
> but I don't think so.  Is there really a happens-before relationship
> between a constructor of an object with no volatile or final fields
> and its finalizer?

My recollection - and I've been trying to find this in the JavaMemoryModel
archives - is that the happens-before between constructor and finalizer was
introduced because the normal "trick" of using synchronization was very
counter-intuitive in constructors given the object has not been published.

That said, A happens-before B simply establishes visibility/ordering rules
for the case when A occurs before B. It says nothing about B occurring
before A, or B and A overlapping. Other mechanisms have to force the
temporal order. So it may be I misspoke my support of Justin's position. :(


> Andrew.
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest

More information about the Concurrency-interest mailing list