RFR: CODETOOLS-7903091: Convert jtreg to use NIO
Jonathan Gibbons
jjg at openjdk.java.net
Mon Feb 7 22:54:45 UTC 2022
Please review a medium-big, conceptually simple but occasionally tricky update to jtreg, to use `java.nio.file.Path` instead of `java.io.File` where reasonable.
While most of the changes are formulaic and follow the obvious patterns, there were some noteworthy points:
* The most complicated class to change was `Locations`, which does the most work to derive new paths. In particular, the semantics of `new File(a, b)` do not always match `Path.of(a).resolve(b)` for corner cases like when `a` is`null` or empty, or when `b` is absolute.
* The NIO equivalent for some operations on `File` now throw checked exceptions. These methods were wrapped to to throw a custom unchecked IO exception.
* The NIO equivalent for creating a new file (path) throws an unchecked IO exception. The use sites are too numerous to handle individually. The solution is to catch exceptions like these (and the ones described in the previous bullet) at strategic points where they can be handled or wrapped back into (existing) checked exceptions.
The development has been iterative, frequently running the jtreg internal tests locally (on a Mac) and occasionally building on a CI system (Linux). We should do more exhaustive testing with JDK before this work ever gets promoted.
-------------
Commit messages:
- CODETOOLS-7903091: Convert jtreg to use NIO
Changes: https://git.openjdk.java.net/jtreg/pull/50/files
Webrev: https://webrevs.openjdk.java.net/?repo=jtreg&pr=50&range=00
Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7903091
Stats: 1299 lines in 38 files changed: 419 ins; 98 del; 782 mod
Patch: https://git.openjdk.java.net/jtreg/pull/50.diff
Fetch: git fetch https://git.openjdk.java.net/jtreg pull/50/head:pull/50
PR: https://git.openjdk.java.net/jtreg/pull/50
More information about the jtreg-dev
mailing list