RFR: 8253402: Convert vmSymbols::SID to enum class
Vladimir Kozlov
kvn at openjdk.java.net
Fri Sep 25 19:18:44 UTC 2020
On Thu, 24 Sep 2020 20:31:20 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> No, don't move them to globalDefinitions.hpp, only have the forward declarations where they're used. So this is like a
>> class forward declaration? neat.
>
> How about having a new header file utilities/vmEnums.hpp that looks like this:
>
> // Include this header file if you just need the following enum types and
> // you don't use their members directly. This way you don't need to include the
> // complex header files that have the full definitions of these enums.
> enum JVMFlagsEnum : int;
> enum class vmSymbolID : int;
>
> My plan is to have at least 2 more such enums (one for `vmIntrinsics::ID`, and one for `SystemDictionary::WKID`).
>
> `: int` is the base type of the enum. I think that's part of the type's implementation so it shouldn't be exposed to
> the user of these types. If we litter `enum class vmSymbolID : int;` all over, when we decide to change the base type
> to something else, we would need to edit all such places. Worse, if your forward declaration is wrong, like
>
> enum class vmSymbolID : char;
>
> the compiler won't detect this if your source file doesn't *also* include vmSymbols.hpp, so it could be dangerous.
I am okay with this suggestion.
-------------
PR: https://git.openjdk.java.net/jdk/pull/276
More information about the hotspot-dev
mailing list