Use `ClassLoaderIndex` to index class-loader related information by mcculls · Pull Request #9980 · DataDog/dd-trace-java

What Does This Do

ClassLoaderIndex provides a stable numeric key-id for each live class-loader which can be used to record class-loader origin and match against it without storing weak references everywhere. (The index itself uses weak references, but clients using the index can simply use the numeric key-id.)

Note a class-loader may have more than one key-id over its life if it is temporarily displaced from the index. For example if a large number of class-loaders (>500) happened to be created in parallel. This would be very unusual, and at worst any cached type info under the old key-id would no longer match. This just means the type info would be recomputed and cached under the new key-id.

Motivation

Reduces direct use of class-loader weak references in the codebase.

Contributor Checklist

Jira ticket: APMAPI-1654