RFR: 8231179: Investigate why tools/javac/options/BCPOrSystemNotSpecified.java fails on Window [v4]

Guoxiong Li github.com+13688759+lgxbslgx at openjdk.java.net
Thu Apr 15 01:50:16 UTC 2021


> Hi all,
> 
> The statement `String sourcePath = file.getName();` in method `prepareBCP(Path target)` would use `DirectoryFileObject::getName` which is shown below.
> 
> 
> @Override @DefinedBy(Api.COMPILER)
> public String getName() {
>     return relativePath.resolveAgainst(userPackageRootDir).toString();  // <-----------------
> }
> 
> 
> And the `DirectoryFileObject::getName` would use `RelativePath::resolveAgainst` which is shown below
> 
> 
> public Path resolveAgainst(Path directory) throws /*unchecked*/ InvalidPathException {
>     String sep = directory.getFileSystem().getSeparator();  // <---------------------
>     return directory.resolve(path.replace("/", sep));
> }
> 
> 
> We can see that `RelativePath::resolveAgainst` use file system separator instead of operating system separator. In method `prepareBCP`, the file system should be JRT file system, but we don't need to know actually which file system to be used. We only need to use the same file system separator so that the test can run as expected.
> 
> This patch fixes the test by using the file system separator instead of operating system separator.
> 
> Thank you for taking the time to review.
> 
> Best Regards.

Guoxiong Li has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:

 - Merge branch 'master' into JDK-8231179
 - Merge branch 'master' into JDK-8231179
 - Use StandardJavaFileManager::asPath
 - Modify copyright
 - 8231179: Investigate why tools/javac/options/BCPOrSystemNotSpecified.java fails on Window

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2004/files
  - new: https://git.openjdk.java.net/jdk/pull/2004/files/0cfaae62..a2887ee3

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2004&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2004&range=02-03

  Stats: 221708 lines in 6269 files changed: 133763 ins; 52529 del; 35416 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2004.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2004/head:pull/2004

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


More information about the compiler-dev mailing list