RFR: 8374549: Extend MetaspaceClosure to cover non-MetaspaceObj types

Ioi Lam iklam at openjdk.org
Fri Jan 23 16:30:31 UTC 2026


On Fri, 23 Jan 2026 15:38:24 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:

> > PackageEntry, ModuleEntry and GrowableArray cannot be subclasses from MetaspaceObject due to various constraints.
> 
> @iklam what prevents `PackageEntry` and `ModuleEntry` from being a subclass of `MetaspaceObject`?

These objects are allocated while holding the `Module_lock`. However, allocations from metaspace cannot be done while holding a native lock -- before metsapce is expanded, the JVM triggers a GC to reclaim metadata held by dead classes, but GCs cannot happen while a native lock is being held.

Currently we have other types that aren't really in the metaspace but are declared as subclasses of `MetaspaceObject` (e.g., `KlassTrainingData`, `AdapterHandlerEntry`) just so that they can be visited by `MetaspaceClosure`. These are actually malloc'ed. After this PR, I plan to make a follow-up PR to change these to no subclass from `MetaspaceObject`

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

PR Comment: https://git.openjdk.org/jdk/pull/29049#issuecomment-3791096921


More information about the hotspot-dev mailing list