RFR: 8363584: Sort share/utilities includes [v6]

Francesco Andreuzzi duke at openjdk.org
Thu Jul 24 10:57:36 UTC 2025


On Thu, 24 Jul 2025 08:49:41 GMT, Francesco Andreuzzi <duke at openjdk.org> wrote:

>> @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`)
>
> Fixed in 6c8507a09d1f2e9956ce18b14993382622e6741f, I manually removed the comment, ran the tool, and re-applied the comments. Should be good enough, but I wonder if such operation could be done by the tool automagically?

> And the comment for <stdio.h> is odd, since that's already being brought in by <stdarg.h>.

I see @kimbarrett, fixed in 8ebbfaf61823933895ab3757d352eaa90051fde8. I simply removed the comment

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26428#discussion_r2228175768


More information about the hotspot-dev mailing list