RFR: JDK-8274172: Convert JavadocTester to use NIO [v3]

Pavel Rappo prappo at openjdk.java.net
Fri Sep 24 17:11:57 UTC 2021


On Fri, 24 Sep 2021 17:02:53 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> test/langtools/tools/lib/toolbox/ToolBox.java line 277:
>> 
>>> 275:             if (toDir.getParent() != null) {
>>> 276:                 Files.createDirectories(toDir.getParent());
>>> 277:             }
>> 
>> This is exactly what I was going to re-suggest after I read your reply on my initial suggestion. We're on the same page. Thanks for simplifying this stuff.
>
> Actually, we could simplify it to an unconditional  `Files.createDirectories(toDir.toAbsolutePath().getParent())`

Hm...

jshell> Path.of("/").getParent()
$1 ==> null

jshell> Path.of("/").toAbsolutePath().getParent()
$2 ==> null

jshell> /reset
|  Resetting state.

jshell> Path.of("/").getParent()
$1 ==> null

jshell> Path.of("/").toAbsolutePath().getParent()
$2 ==> null

jshell> Files.createDirectories(null)
|  Exception java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.getFileSystem()" because "path" is null
|        at Files.provider (Files.java:105)
|        at Files.createDirectory (Files.java:700)
|        at Files.createAndCheckIsDirectory (Files.java:807)
|        at Files.createDirectories (Files.java:753)
|        at (#3:1)

-------------

PR: https://git.openjdk.java.net/jdk/pull/5644


More information about the javadoc-dev mailing list