[concurrency-interest] Unsafe publication of new objectsquestion

Andrew Trick andrew.trick at gmail.com
Fri Nov 12 22:34:19 EST 2010

I thought the original question referred to object instantiation, not
the call to <init>. Setting up the object header and zeroing fields
obviously requires a barrier.

On Fri, Nov 12, 2010 at 7:12 PM, David Holmes <davidcholmes at aapt.net.au> wrote:
> Justin T. Sampson writes:
>> On Fri, Nov 12, 2010 at 2:16 PM, David Holmes <davidcholmes at aapt.net.au>
> wrote:
>>> Andrew Trick writes:
>>> > The JVM needs an effective store-store memory barrier between all
>>> > stores that initialize a new object and any store that may publish a
>>> > pointer to it. Not easy to do efficiently on all architectures.
>>> The JVM would need this if it were to guarantee safe-publication, but it
>>> doesn't guarantee that.
>> It does for final fields, right? Or is that a different concept?
> There are additional guarantees regarding the initialization of final
> fields. I suggest reading Section 17.5 of the Java Language Specification
> for the details, but for a simple formulation see the "Final Fields" section
> of the JMM Cookbook:
> http://gee.cs.oswego.edu/dl/jmm/cookbook.html
> Cheers,
> David Holmes
> _______________________________________________
> 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