Closed ganschen closed 6 days ago
If any of your instrumentations requires dispatch to an object, it is required. But normally it is not. I will see if I can change it to detect this automatically. But unless you do something like MethodDelegation.to(new MyDispatcher())
, it should be safe.
Thank you for your explanation!
Background
I wrote a ThreadSubclassInterceptor to transform Thread's Subclass.
I ran the JDK test and exception thrown.
I found that it's because ProxyServer extends thread class so it will be instrumented, and because of AgentBuilder's default strategy, code below will be added.
While in the policy of the test, there is no
getClassLoader
permission, so the exception will be thrown.I tried to change the strategy to
InitializationStrategy.NoOp
and it worked but still not sure if it's safe to do so.Question
May i know In which case it's safe to change the InitializationStrategy to NoOp or Minimal? I tried to understand InitializationStrategy.SelfInjection's behaviour by reading the source code, looks like what it's trying to do is to call the LoadedTypeInitializer registered in the instrumented type and it's auxiliary types, but it's still not very clear to me what does those LoadedTypeInitializers do, can i get some explanation is detail or some examples? Thank you so much.