JDK-8217168 : Files.isHidden should return true for hidden directories on Windows
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 13
  • Submitted: 2019-01-15
  • Updated: 2019-01-18
  • Resolved: 2019-01-18
Related Reports
CSR :  
Description
Summary
-------

Remove the verbiage in the specification of java.nio.file.Files.isHidden() which states that a folder on Windows cannot be hidden.

Problem
-------

Currently a Windows folder can have its 'hidden' attribute set but Files.isHidden() will return 'false' for the folder.

Solution
--------

Allow Files.isHidden() to reflect the value of the 'hidden' attribute.

Specification
-------------

Diff:

```
--- a/src/java.base/share/classes/java/nio/file/Files.java
+++ b/src/java.base/share/classes/java/nio/file/Files.java
@@ -1608,12 +1608,13 @@
     }
 
     /**
-     * Tells whether or not a file is considered <em>hidden</em>. The exact
-     * definition of hidden is platform or provider dependent. On UNIX for
-     * example a file is considered to be hidden if its name begins with a
-     * period character ('.'). On Windows a file is considered hidden if it
-     * isn't a directory and the DOS {@link DosFileAttributes#isHidden hidden}
-     * attribute is set.
+     * Tells whether or not a file is considered <em>hidden</em>.
+     *
+     * @apiNote
+     * The exact definition of hidden is platform or provider dependent. On UNIX
+     * for example a file is considered to be hidden if its name begins with a
+     * period character ('.'). On Windows a file is considered hidden if the DOS
+     * {@link DosFileAttributes#isHidden hidden} attribute is set.

```

Updated specification:

```
    /**
     * Tells whether or not a file is considered <em>hidden</em>.
     *
     * @apiNote
     * The exact definition of hidden is platform or provider dependent. On UNIX
     * for example a file is considered to be hidden if its name begins with a
     * period character ('.'). On Windows a file is considered hidden if the DOS
     * {@link DosFileAttributes#isHidden hidden} attribute is set.
     *
     * <p> Depending on the implementation this method may require to access
     * the file system to determine if the file is considered hidden.
     *
     * @param   path
     *          the path to the file to test
     *
     * @return  {@code true} if the file is considered hidden
     *
     * @throws  IOException
     *          if an I/O error occurs
     * @throws  SecurityException
     *          In the case of the default provider, and a security manager is
     *          installed, the {@link SecurityManager#checkRead(String) checkRead}
     *          method is invoked to check read access to the file.
     */
    public static boolean isHidden(Path path) throws IOException {}
```

Comments
Moving to Approved for JDK 13.
18-01-2019