Hi Brian,
I expect the original user.dir property to be kept resident in memory by
System.properties
(thus no memory loss), and going from a boolean field to an Object
reference field on an
object that I expect to be a singleton(?) is unlikely to be a footprint
concern[1].
/Claes
[1] Chances are the two approaches are footprint neutral on most archs
due to padding.
On 2018-03-12 19:46, Brian Burkhalter wrote:
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 <mailto: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;