On Fri, 24 Sep 2021 17:02:53 GMT, Jonathan Gibbons <j...@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

Reply via email to