From 3033e6f421d0f6e0aea1d976a806d7abca7c6360 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 21 Jan 2026 14:55:26 +0000 Subject: [PATCH] 8375544: JfrSet::clear should not use memset Reviewed-by: mgronlun --- src/hotspot/share/jfr/utilities/jfrSet.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/jfr/utilities/jfrSet.hpp b/src/hotspot/share/jfr/utilities/jfrSet.hpp index 3d394d10d8b..c443434800a 100644 --- a/src/hotspot/share/jfr/utilities/jfrSet.hpp +++ b/src/hotspot/share/jfr/utilities/jfrSet.hpp @@ -26,6 +26,7 @@ #define SHARE_JFR_UTILITIES_JFRSET_HPP #include "cppstdlib/new.hpp" +#include "cppstdlib/type_traits.hpp" #include "jfr/utilities/jfrTypes.hpp" #include "memory/allocation.hpp" @@ -110,7 +111,14 @@ class JfrSetStorage : public AnyObj { } void clear() { - memset(_table, 0, _table_size * sizeof(K)); + for (unsigned i = 0; i < _table_size; ++i) { + if constexpr (std::is_copy_assignable_v) { + _table[i] = K{}; + } else { + _table[i].~K(); + ::new (&_table[i]) K{}; + } + } } };