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

(fs) Files::isWritable returns false on a writeable root directory (win)

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 13
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_10

      Description

      jdeps uses `Files.isWritable(Path)` in `JdepsTask.java` to validate a user-given target path for generated dot and/or module-info.java files.

      That `Files.isWritable(Path)` method returns `false` on Windows, although the given path represents a directory the current user has write access to.

      Here's an example for the default "C:\" root directory:

      jshell> Path.of("C:\\").toFile().canWrite()
      $10 ==> true
      jshell> Files.isWritable(Path.of("C:\\"))
      $11 ==> false

      Here are the two usages of `Files.isWritable(Path)`:
      - https://github.com/openjdk/jdk/blob/7256d38458190c2e538b1082dcaca575f2dd5d6d/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java#L614
      - https://github.com/openjdk/jdk/blob/7256d38458190c2e538b1082dcaca575f2dd5d6d/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java#L621

      Workaround:
      Provide a non-existing directory to take the first exit of the two `if`-clauses linked above to by-pass the call of `Files.isWritable(Path)`.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                cstein Christian Stein
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: