RFR: 8327246: Add a jcmd diagnostic command to list the jar files loaded by a process [v2]
David Holmes
dholmes at openjdk.org
Tue Jan 13 05:36:44 UTC 2026
On Fri, 9 Jan 2026 17:26:04 GMT, Larry Cable <duke at openjdk.org> wrote:
>> src/hotspot/share/oops/instanceKlass.cpp line 2406:
>>
>>> 2404: oop loc = cs->obj_field(locfd.offset());
>>> 2405:
>>> 2406: if (loc != nullptr && loc->klass() == vmClasses::String_klass()) {
>>
>> Why are you checking the class type?
>
> I am simply reusing an existing pattern I found elsewhere in the corpus where code that accessed a field by name with the intent to process as a String tested the type, its my practice to code with safety, while its unlikely that the type of the field will change, I think its safer to test prior to invoking a type specific API.
>
> If you feel strongly about this, I will remove the klass comparision. :)
Again an assertion would be better to catch this unlikely scenario. Though I suspect if the type of the field were to change then the use of the field would already trigger an assertion elsewhere.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29048#discussion_r2684886074
More information about the hotspot-dev
mailing list