Helper class classloading issue #5607
Replies: 2 comments 3 replies
-
I don't think the helper classes are normally initialized in the agent (extension) class loader. Maybe you are referencing the class directly from your InstrumentationModule?
what kind of state do you want to collect during transformation? can that be collected in the static initializer of your helper class instead? |
Beta Was this translation helpful? Give feedback.
-
@kamilharksealights what you have observed is the expected behaviour. The classes that are used during transformation are in a different class loader (in agent or extension class loader) from the helpers that are used from the transformed bytecode (are in the same class loader as the transformed class). If you are already building your own agent jar you can just add classes to the agent jar, these will be available in boot loader and you can use them to exchange information between transformation and runtime code. You may need to use a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have an agent extension providing InstrumentationModule that uses a helper class (listed in getAdditionalHelperClassNames)
While transforming the code I use this helper class to register some state, let's say I want to store all methods I transformed.
I also inject some bytecode to the methods with usage of this helper class.
The issue is that this helper class is loaded twice by two classloaders
and because of that the state I collect during transformation is not available at runtime
I guess, it would all work if my class was loaded by bootstrap classloader, by I have no clue how to do that
(I use gradle to produce the final agent jar, with extensions folder with my code inside)
Beta Was this translation helpful? Give feedback.
All reactions