hb from the end of a constructor of an object ot the start of finilizer
jeremymanson at google.com
Mon Jul 14 05:29:44 UTC 2014
It's probably worth noting that the guarantee mostly implies that
non-trivial finalizers probably won't be able to run until the object's
(I imagine that VMs *could* do analysis to figure out when a finalizer can
run even without the constructor on the object finishing, but it would
seriously not be worth it.)
On Sat, Jul 12, 2014 at 7:52 PM, David Holmes <david.holmes at oracle.com>
> 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
More information about the hotspot-dev