ある注釈で注釈を付けられたすべてのメソッドが特定のクラスに委任されるpremain()があります。一般的に、私は次のようになります。デバッガを使用してByteBuddy MethodDelegationがJavaエージェントで動作しない
public static void premain(final String agentArguments, final Instrumentation instrumentation) {
CountingInterception ci = new CountingInterception();
new AgentBuilder.Default()
.type(ElementMatchers.isAnnotatedWith(com.codahale.metrics.annotation.Counted.class))
.transform((builder, type, classLoader, module) ->
builder.method(ElementMatchers.any())
.intercept(MethodDelegation.to(ci))
).installOn(instrumentation);
}
は、この部分が処理されていることを示しているが、注釈付きメソッドが呼び出された場合、何も起こりません。
CountingInterceptionは、任意のヒントについては、この
public class CountingInterception {
@RuntimeType
public Object intercept(@DefaultCall final Callable<?> zuper, @Origin final Method method, @AllArguments final Object... args) throws Exception {
String name = method.getAnnotation(Counted.class).name();
if (name != null) {
// do something
}
return zuper.call();
}
}
おかげのように見えます! ByteBuddy 1.6.9
感謝を。 – micfra