diff --git a/src/hotspot/share/gc/x/xMark.cpp b/src/hotspot/share/gc/x/xMark.cpp index e4e5c25f34fae..016c570261552 100644 --- a/src/hotspot/share/gc/x/xMark.cpp +++ b/src/hotspot/share/gc/x/xMark.cpp @@ -367,8 +367,10 @@ void XMark::mark_and_follow(XMarkContext* context, XMarkStackEntry entry) { const oop obj = XOop::from_address(addr); follow_object(obj, finalizable); - // Try deduplicate - try_deduplicate(context, obj); + if (!finalizable) { + // Try deduplicate + try_deduplicate(context, obj); + } } } } diff --git a/src/hotspot/share/gc/z/zMark.cpp b/src/hotspot/share/gc/z/zMark.cpp index 8bfca55a6b4ba..eb342495f5799 100644 --- a/src/hotspot/share/gc/z/zMark.cpp +++ b/src/hotspot/share/gc/z/zMark.cpp @@ -457,8 +457,10 @@ void ZMark::mark_and_follow(ZMarkContext* context, ZMarkStackEntry entry) { const oop obj = to_oop(addr); follow_object(obj, finalizable); - // Try deduplicate - try_deduplicate(context, obj); + if (!finalizable) { + // Try deduplicate + try_deduplicate(context, obj); + } } } }