RFR: JDK-8274172: Convert JavadocTester to use NIO [v2]
Jonathan Gibbons
jjg at openjdk.java.net
Fri Sep 24 16:54:05 UTC 2021
On Fri, 24 Sep 2021 15:29:47 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
>> test/langtools/tools/lib/toolbox/ToolBox.java line 283:
>>
>>> 281: if (!Files.isDirectory(toSubdir))
>>> 282: throw e;
>>> 283: }
>>
>> If we do not expect the target directory to ever exist, we should remove this try-catch. This would make us fail fast, rather than add something to the existing file tree silently. Also, this situation could only happen in the first call to this method, right?
>> Suggestion:
>>
>> Files.copy(fromSubdir, toSubdir);
>
> Let me clarify my sloppy writing.
>
>> this situation could only happen in the first call to this method
>
> Here I wanted to convey that if FileAlreadyExistsException is NOT thrown during the first call to preVisitDirectory, then this exception will NOT be thrown during subsequent calls to that same method, assuming we're exclusively modifying this tree. Indeed, if we are copying directory, then the first call to the visitor will be to this very method. If the target directory does not already exist, then neither do any subdirectories.
>
> This FileVisitor example hints why there are no convenience methods for file tree copying: there are many ways to copy a file tree.
This is generally getting out of scope. I'm not interested in solving the general "how to copy a file tree" problem at this time (especially if there is no general solution, as evidenced by the lack of public API for this), and this PR is effectively blocking other more interesting, more important work on `DocCommentTester`.
I've reduced the code down to a very basic simple implementation, that is sufficient for the one test that needs it. If necessary, we could move the code into that one test, but I still think it is sufficiently useful and in the spirit of `ToolBox` to provide a basic _copy directory_ functionality.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5644
More information about the javadoc-dev
mailing list