Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 6 commits into from

Conversation

lgxbslgx
Copy link
Member

@lgxbslgx lgxbslgx commented Jan 8, 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.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

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

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/2004/head:pull/2004
$ git checkout pull/2004

Update a local copy of the PR:
$ git checkout pull/2004
$ git pull https://git.openjdk.java.net/jdk pull/2004/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2004

View PR using the GUI difftool:
$ git pr show -t 2004

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/2004.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 8, 2021

👋 Welcome back lgxbslgx! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Jan 8, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jan 8, 2021

@lgxbslgx The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler label Jan 8, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jan 8, 2021

Webrevs

@@ -206,7 +209,9 @@ private void prepareBCP(Path target) throws IOException {
Files.createDirectories(targetDir);
try (InputStream in = file.openInputStream()) {
String sourcePath = file.getName();
int sepPos = sourcePath.lastIndexOf(fileSep);
// Here, we should use file system separator instead of the operating system separator.
String fileSystemSep = ((PathFileObject) file).getPath().getFileSystem().getSeparator();
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using: System.getProperty("file.separator")?

Copy link
Contributor

@jonathan-gibbons jonathan-gibbons Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicente-romero-oracle That would be incorrect.
That system property is for the default file system, and may not be the correct separator for a user-defined file system, as is possible with java.nio.file.FileSystem

Copy link
Contributor

@jonathan-gibbons jonathan-gibbons Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicente-romero-oracle Explaining a bit more ... on Windows, the default file system separator is \ but we're dealing here with Path objects from the "internal" JRT file system, which uses / as a separator. That's why we have to be careful to use the right separator. On Unix/Linux/macOS, the separators are the same, which is how the test has passed on those platforms.

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see thanks for the clarification

@@ -206,7 +209,9 @@ private void prepareBCP(Path target) throws IOException {
Files.createDirectories(targetDir);
try (InputStream in = file.openInputStream()) {
String sourcePath = file.getName();
int sepPos = sourcePath.lastIndexOf(fileSep);
// Here, we should use file system separator instead of the operating system separator.
String fileSystemSep = ((PathFileObject) file).getPath().getFileSystem().getSeparator();
Copy link
Contributor

@jonathan-gibbons jonathan-gibbons Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to get the Path without having to cast to the internal PathFileObject type.

See https://docs.oracle.com/en/java/javase/15/docs/api/java.compiler/javax/tools/StandardJavaFileManager.html#asPath(javax.tools.FileObject)

Copy link
Member Author

@lgxbslgx lgxbslgx Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathan-gibbons Thanks for your suggestion. I have updated the code.

@lgxbslgx
Copy link
Member Author

@lgxbslgx lgxbslgx commented Jan 21, 2021

I find the windows-x64-build of the pre-submit-tests failed. I merge the code of the master branch to try to fix it.

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Feb 18, 2021

@lgxbslgx This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@lgxbslgx
Copy link
Member Author

@lgxbslgx lgxbslgx commented Apr 15, 2021

I merged the code of the master branch just now to see whether the tools/javac/options/BCPOrSystemNotSpecified.java passes the Pre-submit test. If so, maybe it is time for us to push this patch.

# Conflicts:
#	test/langtools/ProblemList.txt
@lgxbslgx
Copy link
Member Author

@lgxbslgx lgxbslgx commented Apr 19, 2021

I merged the master branch to solve the conflict. Thank you for reviewing.

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

looks good to me

@openjdk
Copy link

@openjdk openjdk bot commented Apr 23, 2021

@lgxbslgx This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

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

Reviewed-by: vromero

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 108 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@jonathan-gibbons, @vicente-romero-oracle) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Apr 23, 2021
@lgxbslgx
Copy link
Member Author

@lgxbslgx lgxbslgx commented Apr 23, 2021

@vicente-romero-oracle Thank you for your review. Could I get your help to sponsor this patch?

/integrate

@openjdk openjdk bot added the sponsor label Apr 23, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 23, 2021

@lgxbslgx
Your change (at version 40fa1b7) is now ready to be sponsored by a Committer.

@vicente-romero-oracle
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle commented Apr 24, 2021

/sponsor

@openjdk openjdk bot closed this Apr 24, 2021
@openjdk openjdk bot added integrated and removed sponsor ready rfr labels Apr 24, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 24, 2021

@vicente-romero-oracle @lgxbslgx Since your change was applied there have been 113 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit 4b7f027.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@lgxbslgx lgxbslgx deleted the JDK-8231179 branch Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler integrated
3 participants