Odd result with canonical paths with intermixed usage of java.io.File and java.nio.file.Files APIs

Jaikiran Pai jai.forums2013 at gmail.com
Mon Dec 11 16:43:45 UTC 2017

On 11/12/17 9:43 PM, Alan Bateman wrote:
> On 11/12/2017 15:46, Jaikiran Pai wrote:
>> Thanks Alan. Given that the cache itself is being planned to be 
>> eventually removed, that answers the main part of my question and I 
>> can workaround this issue in a couple of ways (disabling the cache 
>> using that system property is one way) in the application, till that 
>> time.
>> The only remaining part that I'm curious about is this:
>> > ... would it be a better idea (as an application developer) to use 
>> Path.toRealPath[2] instead of using the File.getCanonicalPath()? Are 
>> these 2 APIs semantically equivalent? The File.getCanonicalPath() 
>> talks about the canonical path being "unique" paths but the 
>> Path.toRealPath has no such mentions.
> The main semantic difference is that toRealPath method can only return 
> the real path of existing file (the file must exist). I don't know if 
> that helps with your scenario or not.
It won't help in the specific case where I was thinking of using this, 
but it's a good detail to know. Thank you.


More information about the core-libs-dev mailing list