RFR: 8319242: HotSpot Style Guide should discourage non-local variables with non-trivial initialization or destruction [v2]
Kim Barrett
kbarrett at openjdk.org
Mon Jun 16 12:04:12 UTC 2025
On Mon, 16 Jun 2025 08:05:16 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> Kim Barrett has updated the pull request incrementally with one additional commit since the last revision:
>>
>> better terminology, merge separate sections
>
> 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?
The term I was looking for but didn't find earlier is "dynamic initialization"
(C++14 3.6.2). (I should have remembered the terminology, since it came up in
the context of `thread_local`.) I've revised the text accordingly.
I also (re)discovered that that there was already some discussion of this
topic later in the guide, in the "Excluded Features" section. That section
also had some problems terminology problems, and was kind of misplaced. I've
merged that into this new section, hopefully overall improving things.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25812#discussion_r2149809405
More information about the hotspot-dev
mailing list