Integrated: 8231179: Investigate why tools/javac/options/BCPOrSystemNotSpecified.java fails on Window

Guoxiong Li gli at openjdk.java.net
Sat Apr 24 02:22:25 UTC 2021


On Fri, 8 Jan 2021 13:33:34 GMT, Guoxiong Li <gli at openjdk.org> wrote:

> 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.

This pull request has now been integrated.

Changeset: 4b7f0274
Author:    Guoxiong Li <gli at openjdk.org>
Committer: Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/4b7f0274
Stats:     10 lines in 2 files changed: 6 ins; 1 del; 3 mod

8231179: Investigate why tools/javac/options/BCPOrSystemNotSpecified.java fails on Window

Reviewed-by: vromero

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

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


More information about the compiler-dev mailing list