Skip to content

8363584: Sort share/utilities includes #26428

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fandreuz
Copy link
Contributor

@fandreuz fandreuz commented Jul 22, 2025

This PR sorts the includes in hotspot/share/utilities using test/hotspot/jtreg/sources/SortIncludes.java. I'm also adding the directory to TestIncludesAreSorted.java.

Passes tier1 tests and GHA.


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-8363584: Sort share/utilities includes (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26428/head:pull/26428
$ git checkout pull/26428

Update a local copy of the PR:
$ git checkout pull/26428
$ git pull https://git.openjdk.org/jdk.git pull/26428/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26428

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26428.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 22, 2025

👋 Welcome back fandreuz! 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 Jul 22, 2025

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

8363584: Sort share/utilities includes

Reviewed-by: shade

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 2 new commits pushed to the master branch:

  • ea6674f: 8315131: Clarify VarHandle set/get access on 32-bit platforms
  • d714b5d: 8356557: Update CodeSource::implies API documentation and deprecate java.net.SocketPermission class for removal

Please see this link for an up-to-date comparison between the source branch of this pull request and 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 (@shipilev) 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 rfr Pull request is ready for review label Jul 22, 2025
@openjdk
Copy link

openjdk bot commented Jul 22, 2025

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

  • hotspot

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.

@mlbridge
Copy link

mlbridge bot commented Jul 22, 2025

Webrevs

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. Need to wait for builds to complete, 24 hours cooldown, and have another Reviewer.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 22, 2025
# include <stdint.h>
# include <stdlib.h>
# include <string.h>
# include <stddef.h>// for offsetof
# include <sys/stat.h>
# include <io.h> // for stream.cpp
# include <float.h> // for _isnan
# include <stdio.h> // for va_list

Choose a reason for hiding this comment

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

These aren't being flagged as out of order by the checker, because of the trailing comments.
And the comment for <stdio.h> is odd, since that's already being brought in by <stdarg.h>.

Copy link
Contributor Author

@fandreuz fandreuz Jul 23, 2025

Choose a reason for hiding this comment

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

@kimbarrett How should we tackle this problem? I tried the following:

 # include <stdlib.h>
 # include <string.h>
-# include <stddef.h>// for offsetof
+// for offsetof
+# include <stddef.h>
 # include <sys/stat.h>
-# include <io.h>    // for stream.cpp
-# include <float.h> // for _isnan
-# include <stdio.h> // for va_list
+// for stream.cpp
+# include <io.h>
+// for _isnan
+# include <float.h>
+// for va_list
+# include <stdio.h>
 # include <fcntl.h>
 # include <inttypes.h>
 # include <limits.h>

Then running SortInclude gives the following result:

 # include <float.h>
 // for va_list
-# include <stdio.h>
 # include <fcntl.h>
 # include <inttypes.h>
 # include <limits.h>
+# include <stdio.h>
 # include <time.h>

from which I infer that SortInclude disregards comments above the include statement, which of course is not what we want.

Either we remove the comments, or SortIncludes.java should be improved somehow. For example, I see the following comment in TestIncludesAreSorted:

Note that non-space characters after the closing " or > of an include statement
can be used to prevent re-ordering of the include.

Would it be acceptable to change this behavior to prevent only lines containing a particular combination from being reordered? (e.g. // do not reorder)

# include <inttypes.h>
# include <limits.h>
# include <time.h>

Choose a reason for hiding this comment

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

And these were blocked from reordering across the "no reorder" commented includes.

# include <inttypes.h>
# include <limits.h>
# include <time.h>
// Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES
# include <math.h>

Choose a reason for hiding this comment

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

There's a separate problem, unrelated to include order cleanup, that _USE_MATH_DEFINES is being
defined here, as that's too late if <math.h> happened to be included already. I'll file a bug to address that.
(Apparently not causing problems currently, but include reorderings could trigger problems.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot [email protected] ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants