RFR: 8285452: Add a new test library API to replace a file content using FileUtils.java [v5]

Jaikiran Pai jpai at openjdk.java.net
Fri Apr 29 12:06:45 UTC 2022


On Fri, 29 Apr 2022 10:46:31 GMT, Sibabrata Sahoo <ssahoo at openjdk.org> wrote:

>> A new API to support replacing selective lines with desired content.
>
> Sibabrata Sahoo has updated the pull request incrementally with one additional commit since the last revision:
> 
>   updated to add space character in begining of multiline string

test/lib/jdk/test/lib/util/FileUtils.java line 383:

> 381:      * Patches a part of a file.
> 382:      * @param path of file
> 383:      * @param fromLine the first line to patch. This is the number you see in an editor, 1-based.

Perhaps this should mention whether the `fromLine` is inclusive, like it's noted for the `toLine`?

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?

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

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


More information about the core-libs-dev mailing list