On Tue, 5 Aug 2025 10:07:38 GMT, Johan Sjölen <jsjo...@openjdk.org> wrote:
>> src/hotspot/share/interpreter/bytecodeUtils.hpp line 40: >> >>> 38: // Slot can be nonnegative to indicate an explicit search for the >>> source of null >>> 39: // If slot is negative (default), also search for the action that >>> caused the NPE before >>> 40: // deriving the actual slot and source of null by code parsing >> >> Suggestion: >> >> // Slot can be nonnegative to indicate an explicit search for the source >> of null. >> // If slot is negative (default), also search for the action that caused >> the NPE before >> // deriving the actual slot and source of null by code parsing. >> >> Periods at the end of sentences in comments. > > 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. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26600#discussion_r2254525459