RFR 8198997: Cache normalized/resolved user.dir property

Claes Redestad claes.redestad at oracle.com
Mon Mar 12 18:42:54 UTC 2018


mixing volatiles and non-volatiles fields that are read and written to 
outside of
synchronized makes me somewhat queasy...

Instead of a volatile boolean and a mutable userDir field, couldn't this 
as well be modelled as:

- keep userDir final (always the not normalized value of 
- replace volatile boolean isUserDirNormal with volatile String 
- then implement the DCL in getUserPath like:

String normalizedUserDir = this.normalizedUserDir;
if (normalizedUserDir == null) {
     synchronized(userDir) {
         if (normalizedUserDir == null) {
             normalizedUserDir = this.normalizedUserDir = 
return normalizedUserDir;



On 2018-03-12 19:32, Brian Burkhalter wrote:
> https://bugs.openjdk.java.net/browse/JDK-8198997
> http://cr.openjdk.java.net/~bpb/8198997/webrev.00/
> Lazily cache the value of the user.dir property on first access. This change is for Windows only as there does not appear to be any percentage in doing something similar on Unix.
> Thanks,
> Brian

More information about the core-libs-dev mailing list