Consider the file path "Test.java/foo"where Test.java is a regular file.
On Linux/macOS, the following will throw FileSystemException: Test.java/bar: Not a directory
Files.readAttributes(file, BasicFileAttributes.class);
Files.readAttributes(file, PosixFileAttributes.class);
and both of the following will return false as they can't determine if the file exists:
Files.exists(file);
Files.notExists(file);
We need to examine the mapping of ENOTDIR in at least UnixFileAttributeViews.Basic.readAttributes, UnixFileAttributeViews.Posixr.eadAttributes, , and UnixFileSystemProvider.checkAccess so that ENOTDIR is treated as ENOENT. That would change the above so that readAttributes would throw NoSuchFileException for this "unusual" case, and would mean that Files.notExists can return true.
There may be wider scope to map ENOTDIR to NoSuchFileException but would require a detailed pass to see what methods might be impacted.