RFR 8199435 : Unsafe publication of java.util.Properties.map

Martin Buchholz martinrb at google.com
Mon Jun 18 14:05:24 UTC 2018


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() ?


More information about the core-libs-dev mailing list