RFR: 8191963: Path.equals() and File.equals() return true for two different files on Windows

Brian Burkhalter bpb at openjdk.org
Wed Jun 25 19:35:28 UTC 2025


On Mon, 23 Jun 2025 11:09:30 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> > Just wondering how Windows implementation really behaves for its 'case-insensitive-comparing" for "\u0131 vs "I". I would assume they actually are 2 'distinguished" files?
> 
> I think it depends on the locale. Also it is possible to configure NTFS, on a per directory basis, to disable the directory the case sensitivity. WindowsPath.compareTo is where we ended up for JDK 7, it would be good to validate this.

"Support for per-directory case sensitivity began in Windows 10, build 17107." [*] This is handled on the (PowerShell) command line with

fsutil.exe file setCaseSensitiveInfo <path> [enable | disable]


For the purposes of this request, the `equals` methods operate on the string representation of the abstract pathname and do not interact with the file system. The specification of `File.equals` states

On UNIX systems, alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.

If it were necessary to account for the directory case sensitivity setting, something like the `NtQueryInformationFile` function would be needed. Changing to case-sensitive would likely break a lot of code.

[*] https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25788#issuecomment-3005914556


More information about the core-libs-dev mailing list