-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8338851: Hoist os::Posix::realpath() to os::realpath() and implement on Windows #20683
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
Conversation
👋 Welcome back stooke! A progress list of the required criteria for merging this PR into |
@stooke 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:
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 94 new commits pushed to the
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 (@dholmes-ora, @tstuefe, @TheShermanTanker) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is okay in principle but a few changes can be made.
Also it seems that none of the callers of realpath
ever check errno
so I think that can be removed.
Thanks
Hello, @dholmes-ora , and thank you for your review! I am in the process of attempting to address your concerns. Your review has resulted in simpler code for my implementation - so thanks for that too. Please let me know if you have more concerns or questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the work. One question inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows version looks better now, though still one issue that isn't really solvable - so I'd let it slide (especially as I think the errno settings should be removed anyway).
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay this seems fine to me now.
Thanks
Hello, @dholmes-ora , could you please take another look? I've responded to your concerns about the macOS-specific tests, but I don't know if you feel my response is adequate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @stooke , I was away on vacation when you made the updates.
I'm afraid I still have some issues about expected behaviour on Windows with regard to the tests.
/* Returns ENOENT on Linux, ENAMETOOLONG on Windows */ | ||
EXPECT_TRUE(returnedBuffer == nullptr); | ||
#if defined(_WINDOWS) | ||
EXPECT_TRUE(errno == ENAMETOOLONG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this the case? Our implementation does not set it and _fullpath
makes no mention of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is Windows behaviour - Windows 10 with VS 2022 at least. The existence of a file is not checked, but that non-existent filename better fit into the given buffer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. This behaviour is not specified but the test passed on our CI on Windows Server 2016 and 2019.
#endif | ||
|
||
TEST_VM(os, realpath) { | ||
/* POSIX requires that the file exists, Windows doesn't */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this comment means. I can't fully discern from
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fullpath-wfullpath?view=msvc-170
what Windows does if the path does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can only report by example - on my local machine, Windows doesn't appear to care if the file exists or not, but according to the docs you point to, Windows does care if the drive letter is valid.
Adding an invalid drive letter test is beyond the current scope of this test.
I have expanded this comment to be more explanatory:
// POSIX requires that the file exists;
// Windows tests for a valid drive letter but may or may not test if the file exists.
@dholmes-ora thank you for your comments. I have updated the comments (and reformatted comments and #ifdef code to match the rest of the tests source. |
/* Returns ENOENT on Linux, ENAMETOOLONG on Windows */ | ||
EXPECT_TRUE(returnedBuffer == nullptr); | ||
#if defined(_WINDOWS) | ||
EXPECT_TRUE(errno == ENAMETOOLONG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. This behaviour is not specified but the test passed on our CI on Windows Server 2016 and 2019.
/integrate |
/sponsor |
Going to push as commit 7a64fbb.
Your commit was automatically rebased without conflicts. |
@dholmes-ora @stooke Pushed as commit 7a64fbb. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR changes the status of realpath() from a Posix-specific API to a globally available API, i.e. adding it to the "Hotspot Porting API". Code would refer to os::realpath() instead of os::Posix::realpath().
This requires a Windows implementation of realpath(), using Windows _fullpath(), and renaming os::Posix::realpath() to os::realpath().
The main difference between POSIX and Windows behaviour is that POSIX actually requires an existing accessible file, while Windows will happily work with made-up filenames.
Please note that guidelines for doing this appear in src/hotspot/share/runtime/os.hpp
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20683/head:pull/20683
$ git checkout pull/20683
Update a local copy of the PR:
$ git checkout pull/20683
$ git pull https://git.openjdk.org/jdk.git pull/20683/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20683
View PR using the GUI difftool:
$ git pr show -t 20683
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20683.diff
Webrev
Link to Webrev Comment