Hi Claes, That was what I had originally but did not post as I did not like the extra String variable increasing the memory footprint. Of course this would only be true were the user.dir accessed at all.
Thanks, Brian On Mar 12, 2018, at 11:42 AM, Claes Redestad <claes.redes...@oracle.com> wrote: > Instead of a volatile boolean and a mutable userDir field, couldn't this just > as well be modelled as: > > - keep userDir final (always the not normalized value of > System.getProperty("user.dir")) > - replace volatile boolean isUserDirNormal with volatile String > normalizedUserDir > - then implement the DCL in getUserPath like: > > String normalizedUserDir = this.normalizedUserDir; > if (normalizedUserDir == null) { > synchronized(userDir) { > if (normalizedUserDir == null) { > normalizedUserDir = this.normalizedUserDir = normalize(userDir); > } > } > } > return normalizedUserDir;