Implemented factory for generating invokedynamic proxy classes #9502
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The recently added invokedynamic-based
InstrumentationModule
mechanism changes where helper classes are loaded:Previously, helper classes were injected into the application classloader. With the new mechanism, they instead are loaded in an isolated
InstrumentationModuleClassloader
. While this helps us with the long-term goal of removing shading and improving isolation and debugability of instrumentations, there are some instrumentation where the application classloader actually needs to see certain helper classes.I've identified the following cases by looking at
InstrumentationModules
which register helper resources:We can't just stay with injecting those classes directly: They make use of Otel-SDK/API classes, which we want to remove from the bootstrap in the long term in order to get rid of shading.
To allow the migration of those
InstrumentationModules
to invokedynamic, I've started implementing the proxy approach suggested in this discussion.The idea is to not inject the classes listed above directly, but instead to inject runtime-generated proxies for those classes.
These proxies do not have any direct dependency on classes provided by the agent and therefore can be injected without requiring anything from the bootstrap. The "original" classes for which the proxies are generated are loaded in the
InstrumentationModuleClassloader
and invoked from the proxy classes viainvokedynamic
.This PR only adds the proxy generation and corresponding unit tests. It does not yet add the functionality to
InstrumentationModules
.This will be added with a follow-up PR. I'm thinking of adding a new method to
InstrumentationModule
, which could look somewhat like this:The suggested API should be muzzle friendly and would allow us to extend the functionality in the future without having to introduce more new methods to
InstrumentationModule
.