On Tue, 25 Mar 2025 21:24:41 GMT, Doug Simon <dnsi...@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.
>
> bin/sort_includes.py line 117:
> 
>> 115:                 for filename in filenames:
>> 116:                     file = Path(dirpath).joinpath(filename)
>> 117:                     if file.suffix in (".cpp", "hpp"):
> 
> `"hpp"` -> `".hpp"`
> 
> This bug explains why there are no modified `*.hpp` files in the PR. And I've 
> discovered that blindly sorting includes in these files (especially 
> `*.inline.hpp` files) causes building to break quickly. This is another 
> reason for the more incremental approach I suggest at 
> https://github.com/openjdk/jdk/pull/24180#issuecomment-2752572125

I was going to ask that, but forgot about it once I had looked through all the 
files. :)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24180#discussion_r2013489315

Reply via email to