MetaspaceAllocationTest mimicks ClassLoaderMetaspace creation, allocation and destruction to stress metaspace allocation.
So it runs outside the normal create-allocate-delete cycle in the VM. For instance, there are no associated ClassLoaderData. So, the test needs to mimick the surroundings of the VM.
This means, when creating ClassLoaderMetaspace objects, the test needs to lock its associated lock. In the VM, this happens in ClassLoaderData::metaspace_non_null(), and there the associated lock is pulled before allocation too.
So it runs outside the normal create-allocate-delete cycle in the VM. For instance, there are no associated ClassLoaderData. So, the test needs to mimick the surroundings of the VM.
This means, when creating ClassLoaderMetaspace objects, the test needs to lock its associated lock. In the VM, this happens in ClassLoaderData::metaspace_non_null(), and there the associated lock is pulled before allocation too.