[concurrency-interest] Question about "happens-before" andreordering

Thomas Hawtin tackline at tackline.plus.com
Fri May 19 10:57:53 EDT 2006


Pete Soper wrote:
> 
> This seemed quite clear the first time. More fundamentally, if the 
> constructor never completes, the finalizer's running is impossible, right?

JLS 3 states that the finaliser may (because it never must) run if the 
Object constructor exited normally. 1.6 complies with this (apparently 
even if instrumentation rewrites the Object constructor).

I believe earlier editions of the JLS are silent on this. 1.5 (and I 
presumably earlier versions) will call the finaliser on any object that 
has been allocated. Possibly not even calling the derived most 
constructor. IIRC, javac produced byte code does the new, dups the 
uninitialised reference, evaluates the arguments, then calls the 
<init>(...)V, so even if the arguments are not fully evaluated the 
finaliser is called.

http://www.mernst.org/blog/archives/03-01-2006_03-31-2006.html#46
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4034630

Tom Hawtin


More information about the Concurrency-interest mailing list