RFR: 8319242: HotSpot Style Guide should discourage non-local variables with non-trivial initialization or destruction
Stefan Karlsson
stefank at openjdk.org
Mon Jun 16 08:08:35 UTC 2025
On Sun, 15 Jun 2025 05:15:11 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
> Please review this change to the HotSpot Style Guide to add discussion of how
> we prefer to handle initialization and destruction of non-local variables.
>
> I propose this is an editorial change, as it just documents current practice
> rather than suggesting a change to current practice. As such, the normal
> HotSpot PR process applies.
>
> The updated .html file was generated using make update-build-docs.
doc/hotspot-style.md line 776:
> 774:
> 775: Avoid variables with static storage duration and non-constant initialization,
> 776: or with non-trivial destruction. Such variables can lead to the so-called
I wonder about the phrase "non-constant". There are a few places where we set up static objects that are non-constant, but doesn't depend on anything. For example, `ZGC_ONLY(static ZArguments zArguments;)
`. Is `non-constant` precise enough to describe what we want to prevent?
doc/hotspot-style.md line 777:
> 775: Avoid variables with static storage duration and non-constant initialization,
> 776: or with non-trivial destruction. Such variables can lead to the so-called
> 777: "static initialization order fiasco", or its dual on the destruction size.
What does `destruction size` mean here? Or did you intend to write "destruction site"?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25812#discussion_r2149301958
PR Review Comment: https://git.openjdk.org/jdk/pull/25812#discussion_r2149289222
More information about the hotspot-dev
mailing list