8323158: HotSpot Style Guide should specify more include ordering

Reviewed-by: kbarrett, stuefe, dholmes, kvn
This commit is contained in:
Stefan Karlsson 2025-03-06 07:42:16 +00:00
parent 5c552a9d64
commit 649ef77951
2 changed files with 39 additions and 18 deletions

View File

@ -207,23 +207,31 @@ the simple "getter".</p></li>
<ul>
<li><p>All source files must have a globally unique basename. The build
system depends on this uniqueness.</p></li>
<li><p>Keep the include lines within a section alphabetically sorted.</p></li>
<li><p>Put conditional inclusions (`#if ...`) at the end of the section of HotSpot
include lines. This also applies to macro-expanded includes of platform
dependent files.</p></li>
<li><p>Put system includes in a section after the HotSpot include lines with a blank
line separating the two sections.</p></li>
<li><p>Do not put non-trivial function implementations in .hpp files. If
the implementation depends on other .hpp files, put it in a .cpp or a
.inline.hpp file.</p></li>
the implementation depends on other .hpp files, put it in a .cpp or
a .inline.hpp file.</p></li>
<li><p>.inline.hpp files should only be included in .cpp or .inline.hpp
files.</p></li>
<li><p>All .inline.hpp files should include their corresponding .hpp
file as the first include line. Declarations needed by other files
should be put in the .hpp file, and not in the .inline.hpp file. This
rule exists to resolve problems with circular dependencies between
.inline.hpp files.</p></li>
<li><p>All .inline.hpp files should include their corresponding .hpp file as
the first include line with a blank line separating it from the rest of the
include lines. Declarations needed by other files should be put in the .hpp
file, and not in the .inline.hpp file. This rule exists to resolve problems
with circular dependencies between .inline.hpp files.</p></li>
<li><p>Do not include a .hpp file if the corresponding .inline.hpp file is included.</p></li>
<li><p>Use include guards for .hpp and .inline.hpp files. The name of the defined
guard should be derived from the full search path of the file relative to the
hotspot source directory. The guard should be all upper case with all paths
separators and periods replaced by underscores.</p></li>
<li><p>Some build configurations use precompiled headers to speed up the
build times. The precompiled headers are included in the precompiled.hpp
file. Note that precompiled.hpp is just a build time optimization, so
don't rely on it to resolve include problems.</p></li>
<li><p>Keep the include lines alphabetically sorted.</p></li>
<li><p>Put conditional inclusions (<code>#if ...</code>) at the end of
the include list.</p></li>
</ul>
<h3 id="jtreg-tests">JTReg Tests</h3>
<ul>

View File

@ -135,9 +135,18 @@ change should be done with a "setter" accessor matched to the simple
### Source Files
* All source files must have a globally unique basename. The build
* All source files must have a globally unique basename. The build
system depends on this uniqueness.
* Keep the include lines within a section alphabetically sorted.
* Put conditional inclusions (`#if ...`) at the end of the section of HotSpot
include lines. This also applies to macro-expanded includes of platform
dependent files.
* Put system includes in a section after the HotSpot include lines with a blank
line separating the two sections.
* Do not put non-trivial function implementations in .hpp files. If
the implementation depends on other .hpp files, put it in a .cpp or
a .inline.hpp file.
@ -146,19 +155,23 @@ a .inline.hpp file.
files.
* All .inline.hpp files should include their corresponding .hpp file as
the first include line. Declarations needed by other files should be put
in the .hpp file, and not in the .inline.hpp file. This rule exists to
resolve problems with circular dependencies between .inline.hpp files.
the first include line with a blank line separating it from the rest of the
include lines. Declarations needed by other files should be put in the .hpp
file, and not in the .inline.hpp file. This rule exists to resolve problems
with circular dependencies between .inline.hpp files.
* Do not include a .hpp file if the corresponding .inline.hpp file is included.
* Use include guards for .hpp and .inline.hpp files. The name of the defined
guard should be derived from the full search path of the file relative to the
hotspot source directory. The guard should be all upper case with all paths
separators and periods replaced by underscores.
* Some build configurations use precompiled headers to speed up the
build times. The precompiled headers are included in the precompiled.hpp
file. Note that precompiled.hpp is just a build time optimization, so
don't rely on it to resolve include problems.
* Keep the include lines alphabetically sorted.
* Put conditional inclusions (`#if ...`) at the end of the include list.
### JTReg Tests
* JTReg tests should have meaningful names.