RFR: 8366543: Clean up include headers in numberSeq

Thomas Schatzl tschatzl at openjdk.org
Mon Sep 1 12:41:43 UTC 2025


On Mon, 1 Sep 2025 11:18:06 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

> Trivial changing to use the correct includes in `numberSeq.hpp/cpp`.
> 
> Test: tier1

Changes requested by tschatzl (Reviewer).

src/hotspot/share/utilities/numberSeq.cpp line 25:

> 23:  */
> 24: 
> 25: #include "memory/allocation.hpp"

My rule is if there is a `.inline.hpp` file, always include it instead of the `.hpp` file in the `.cpp` to be sure to catch everything (the inline.hpp always includes the .hpp); and the allocation.hpp must already be included in `numberSeq.hpp`.

This just gives headaches imo when more code is moved to the `.inline.hpp` file. It works this time because nothing from `CHeapObj` is in the `inline.hpp` file, so technically the removal of this include entirely works (as mentioned in the other comment, `numberSeq.hpp` needs to include `allocation.hpp`).

src/hotspot/share/utilities/numberSeq.hpp line 28:

> 26: #define SHARE_UTILITIES_NUMBERSEQ_HPP
> 27: 
> 28: #include "utilities/ostream.hpp"

`CHeapObj` is from allocation.hpp. So the original include is correct.

Instead of including the other header just for `outputStream`, better forward-declare it in the .hpp file here and include it in the cpp file.

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

PR Review: https://git.openjdk.org/jdk/pull/27031#pullrequestreview-3173451879
PR Review Comment: https://git.openjdk.org/jdk/pull/27031#discussion_r2313831992
PR Review Comment: https://git.openjdk.org/jdk/pull/27031#discussion_r2313820966


More information about the hotspot-gc-dev mailing list