RFR: 8352645: Add tool support to check order of includes

Johan Sjölen jsjolen at openjdk.org
Wed Mar 26 08:48:13 UTC 2025


On Sun, 23 Mar 2025 21:14:47 GMT, Doug Simon <dnsimon at openjdk.org> wrote:

> This PR adds `bin/sort_includes.py`, a python3 script to check that blocks of include statements in C++ files are sorted alphabetically and that there's at least one blank line between user and sys includes (as per the [style guide](https://github.com/openjdk/jdk/blob/master/doc/hotspot-style.md#source-files)).
> This script can also update files with unsorted includes. The second commit in this PR shows the result of running:
> 
> python3 ./bin/sort_includes.py ./src/hotspot
> 
> To prevent an include being reordered, put at least one non-space character after the closing `"` or `>`. See `src/hotspot/share/adlc/archDesc.cpp` for an example.
> 
> Assuming this PR is integrated, jcheck could be updated to use it to ensure include statements remain sorted.

No review from me (though happy to review the Java rewrite), but thank you for doing this :-).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/24180#issuecomment-2753621032


More information about the hotspot-dev mailing list