There's a long history of cheating and setting final fields in
pseudo-constructors readObject and clone, which is well motivated since
Java should really support pseudo-constructors in a better way..
Cheating has used Unsafe or reflection with setAccessible
(CopyOnWriteArrayList.resetLock()).

I haven't had any success actually reproducing any data race failures in
constructors - on modern machines it would only happen if the JIT reordered
the writes.

Doug - would CopyOnWriteArrayList.clone() be slightly safer if it had a
releaseFence() ?

Reply via email to