RFR(JDK12/NIO) 8202285: (fs) Add a method to Files for comparing file contents

Joe Wang huizhe.wang at oracle.com
Thu Sep 20 17:28:47 UTC 2018

On 9/20/18, 12:07 AM, Alan Bateman wrote:
> On 20/09/2018 01:34, Joe Wang wrote:
>> :
>> The purpose of toRealPath is so that we can do a quick Path 
>> comparison by following symlinks if any, I'll add a test to compare a 
>> file and its symbolic link. 
> You don't need it. If two non-equals paths locate the same file then 
> mismatch will do the right thing. By dropping it then you avoid a 
> potentially expensive realpath (x2).
>> ProviderMismatchExcepiton was added in one of the iterations when we 
>> defined UOE, shall be removed in the next update (I'll have an update 
>> after some performance work to compare with direct buffer is done).
> Good.
>> mismatchByAttrs cannot be replaced with isSameFile, it does one edge 
>> case check more than isSameFile when the size of one of the files is 
>> zero. mismatchByAttrs opens the files once vs twice if isSameFile and 
>> size(path) are called.
> Hmm, I think we make this a lot simpler.

Ok, I'll call isSameFile instead, that would get rid of toRealPath too, 
to not let these edge case handling penalize the most, normal use cases. 
The other way around (a bit more cost to the edge cases) shall be fine.


> -Alan

More information about the core-libs-dev mailing list