Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8217168

Files.isHidden should return true for hidden directories on Windows

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Windows folders previously identified as not hidden will be identified as hidden.
    • Interface Kind:
      Java API

      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 {}

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                webbuggrp Webbug Group
                Reviewed By:
                Alan Bateman, Brent Christian
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: