RFR 8198997: Cache normalized/resolved user.dir property
Brian Burkhalter
brian.burkhalter at oracle.com
Mon Mar 12 18:46:13 UTC 2018
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.redestad at 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;
More information about the core-libs-dev
mailing list