On Tue, 5 Aug 2025 14:24:37 GMT, Chen Liang <li...@openjdk.org> wrote:
>> I'd like to see the description for `slot` pushed into an enum, and make any >> negative number except `-1` explicitly forbidden. >> >> ```c++ >> enum class NPESlot : int { >> // docs here >> None = -1, >> // docs here >> Explicit // Anything >= 0 >> }; >> bool get_NPE_message_at(outputStream* ss, Method* method, int bci, NPESlot >> slot) { >> if (slot != NPESlot::None) { >> // Explicit search >> } >> } > > I don't think I know how to use C++ enums. I tried to define this enum in > bytecodeUtils.hpp and use it from jvm.cpp, and don't know how in any way I > can ever express `BytecodeUtils::NullSlot slot = search_slot >= 0 ? > search_slot : ???;` because `NullSlot::Search` or > `BytecodeUtils::NullSlot::Search` or `BytecodeUtils::NullSlot.Search` are all > erroneous. I don't think this may worth the hassle since the attempt to use > C++ enum only creates more pain, unless you tell me how to use it properly. I think I figured out how to use static_cast with C++ enum classes. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26600#discussion_r2254630773