-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back fandreuz! A progress list of the required criteria for merging this PR into |
@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:
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
Please see this link for an up-to-date comparison between the source branch of this pull request and the 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 |
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 reasonable to me. Need to wait for builds to complete, 24 hours cooldown, and have another Reviewer.
# 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 |
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.
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>
.
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.
@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> |
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.
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> |
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.
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.)
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
Issue
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