hb from the end of a constructor of an object ot the start of finilizer
David Holmes
david.holmes at oracle.com
Sun Jul 13 02:52:35 UTC 2014
Hi Winnie,
Not really a hotspot question but a Java Memory Model question.
On 12/07/2014 12:27 PM, Winnie JayClay wrote:
> Hi, on the page 575 of the printed edition it says
>
> There is a happens-before edge from the end of a constructor of an
> object ot the start of finilizer (12.6) for that object.
>
> I can't get from this definition if this applicable to the case when
> I manually invoke finilize() on the object or when GC collects it
> and invokes finilize() or for both?
>
> to put it clearly, say I have class with shared non-volatile and
> non-finile state. object fully intialized in the first thread, in the
> second thread I invoke finilize() on this object, will I have gurantee
> of shared-state visibility? and in case if JVM GC invocation?
The intent of the hb edge is only for the GC case (ie for the thread(s)
responsible for finalization), otherwise finalize() is like any other
method and if you invoke it directly from another thread then the object
must either ensure consistency itself or else was safely-published.
But also note that finalization is problematic in that an object that is
still being used can be finalized - see 12.6.1
David Holmes
> Thanks,
> Winnie
>
More information about the hotspot-dev
mailing list