bytebuddy 无法检测 threadPoolExecutor

fails to instrument threadPoolExecutor by bytebuddy

我遇到了同样的问题post。


当我使用代码工具threadpoolexecutor时,

new AgentBuilder.Default()
            .ignore(ElementMatchers.none())
            .type(ElementMatchers.nameContains("ThreadPoolExecutor"))
            .transform((builder, type, classLoader, module) -> builder
                    .visit(Advice.to(ThreadPoolExecutorAdvice.class).on(ElementMatchers.any()))
            ).installOn(instrumentation);

我遇到了这个错误,如何解决?

 java.lang.IllegalStateException: Cannot represent public org.apache.tomcat.util.threads.ThreadPoolExecutor(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.RejectedExecutionHandler) as given method constant

您可能在检测 Constructor 时尝试注入 Method 实例。切换参数类型,应该可以解决。