FilePermission Canonical path optimization

Alan Bateman Alan.Bateman at
Mon Dec 1 12:50:58 UTC 2014

On 01/12/2014 08:06, deven you wrote:
> Hi All,
>   File.getCanonicalPath() is a very time-consuming method, we observed
> significant performance degradation from some application's startup stage
> with However, lazying load the calls to
> getCanonicalPath() from java.ioFilePermission is straightforward and solve
> this problem effectively. Openjdk bug[1]  tracks this bug and here is the
> patch [2]. Could anyone take a look?
> [1]
> [2]

Do you run with canonicalization cache enabled or disabled? While I 
don't agree with this cache, it seem to mostly eliminate complaints in 
this area after it was added (in JDK 1.4 I think).

As regards the patch then it is a bit ugly. Could you use cpath == null 
instead of introducing a flag? If a flag is required then I think it 
will need a better name. Also if init is split then it might be cleaner 
to have initMask and initCanonicalPath.


More information about the core-libs-dev mailing list