Skip to content

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

Closed
wants to merge 27 commits into from

Conversation

stooke
Copy link
Contributor

@stooke stooke commented Aug 22, 2024

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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8338851: Hoist os::Posix::realpath() to os::realpath() and implement on Windows (Enhancement - P4)

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 22, 2024

👋 Welcome back stooke! 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
Copy link

openjdk bot commented Aug 22, 2024

@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:

8338851: Hoist os::Posix::realpath() to os::realpath() and implement on Windows

Reviewed-by: dholmes, stuefe, jwaters

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 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 (@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 /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Aug 22, 2024

@stooke The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

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

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Aug 22, 2024
@stooke stooke marked this pull request as ready for review August 28, 2024 19:25
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 28, 2024
Copy link
Member

@dholmes-ora dholmes-ora left a 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

@stooke
Copy link
Contributor Author

stooke commented Sep 4, 2024

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.

Copy link
Member

@tstuefe tstuefe left a 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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 5, 2024
Copy link
Contributor

@TheShermanTanker TheShermanTanker left a 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

Copy link
Member

@dholmes-ora dholmes-ora left a 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

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 11, 2024
Copy link
Member

@dholmes-ora dholmes-ora left a 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

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 13, 2024
@stooke
Copy link
Contributor Author

stooke commented Oct 14, 2024

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.

Copy link
Member

@dholmes-ora dholmes-ora left a 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);
Copy link
Member

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.

Copy link
Contributor Author

@stooke stooke Oct 16, 2024

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!

Copy link
Member

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 */
Copy link
Member

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.

Copy link
Contributor Author

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.

@stooke
Copy link
Contributor Author

stooke commented Oct 16, 2024

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

@openjdk openjdk bot removed the rfr Pull request is ready for review label Oct 16, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 16, 2024
/* Returns ENOENT on Linux, ENAMETOOLONG on Windows */
EXPECT_TRUE(returnedBuffer == nullptr);
#if defined(_WINDOWS)
EXPECT_TRUE(errno == ENAMETOOLONG);
Copy link
Member

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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 17, 2024
@stooke
Copy link
Contributor Author

stooke commented Oct 17, 2024

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 17, 2024
@openjdk
Copy link

openjdk bot commented Oct 17, 2024

@stooke
Your change (at version 1467917) is now ready to be sponsored by a Committer.

@dholmes-ora
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 17, 2024

Going to push as commit 7a64fbb.
Since your change was applied there have been 97 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 17, 2024
@openjdk openjdk bot closed this Oct 17, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Oct 17, 2024
@openjdk
Copy link

openjdk bot commented Oct 17, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

None yet

4 participants