RFR: 8231269: CompileTask::is_unloaded is slow due to JNIHandles type checks [v6]

Vladimir Ivanov vlivanov at openjdk.org
Fri Apr 25 21:20:50 UTC 2025


On Fri, 25 Apr 2025 09:52:43 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> I don't think UMH gets to decide whether !nullptr holder is always alive or not, and it is safer to hold on to it.

I looked around and stumbled upon the following code in `ClassLoaderData` [1]. I haven't checked myself, but it looks like a hidden class injected into bootstrap loader has `klass_holder == nullptr` while still is amenable to GC... 

IMO a check for `method->method_holder()->class_loader_data()->is_permanent_class_loader_data()` would do a better job serving the immediate needs and communicating the intentions.

[1]

bool ClassLoaderData::is_permanent_class_loader_data() const {
  return is_builtin_class_loader_data() && !has_class_mirror_holder();
}

// Returns true if the class loader for this class loader data is one of
// the 3 builtin (boot application/system or platform) class loaders,
// including a user-defined system class loader.  Note that if the class
// loader data is for a non-strong hidden class then it may
// get freed by a GC even if its class loader is one of these loaders.
bool ClassLoaderData::is_builtin_class_loader_data() const {
...

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24018#discussion_r2060892632


More information about the hotspot-gc-dev mailing list