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

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

    XMLWordPrintable

Details

    • b20
    • x86
    • 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

              Unassigned Unassigned
              cstein Christian Stein
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: