RFR: 8371216: oopDesc::print_value_on breaks if klass is garbage
Paul Hübner
phubner at openjdk.org
Fri Nov 7 13:31:04 UTC 2025
On Fri, 7 Nov 2025 10:04:35 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> I would not add the helper function for only one case. We already have a bunch of helpers like these. Just test for oop != NULL at the call site.
In the scenario I am referring to, we had an always-non-null oop and went through `CompressedKlassPointers::decode_not_null` (which has like 12 assertions). Most of the time, we failed because of the klass range check. In rare cases for this particular instance, but quite often in often in other cases like [JDK-8366794](https://bugs.openjdk.org/browse/JDK-8366794), the klass was null. I don't think it's sufficient to just check for oop nullness.
I agree with you, it'd be nicer to check at the call site. How do you feel about inlining the proposed function into:
if (obj != nullptr && obj->klass_without_asserts() == vmClasses::String_klass()) {
java_lang_String::print(obj, st);
print_address_on(st);
} else // [...]
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28190#issuecomment-3502572955
More information about the hotspot-dev
mailing list