RFR: 8285452: Add a new test library API to replace a file content using FileUtils.java [v5]
Weijun Wang
weijun at openjdk.java.net
Mon May 2 13:16:45 UTC 2022
On Fri, 29 Apr 2022 15:51:12 GMT, Weijun Wang <weijun at openjdk.org> wrote:
>> test/lib/jdk/test/lib/util/FileUtils.java line 389:
>>
>>> 387: * @throws IOException
>>> 388: */
>>> 389: public static void patch(Path path, int fromLine, int toLine, String from, String to) throws IOException {
>>
>> Should this method check whether the `fromLine` and `toLine` are valid values? Things like, negative value or 0 or `toLine` being less than `fromLine`. I'm not familiar with the expectations of test library code - maybe those checks aren't necessary since this is a test util?
>
> `lines.remove()` and `lines.subList()` will throw the correct exception. Since you asked, we can add it.
Now that we call `subList` at the beginning, I think there's no need to explicitly perform a check.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8360
More information about the core-libs-dev
mailing list