1
我需要在intercept()
得到聲明類的方法的註釋(它裏面的值):ByteBuddy - 進去攔截聲明類的註釋()
@RuntimeType
public static Object intercept(@SuperCall Callable callable, @Origin Method method) throws Exception {
method.getDeclaringClass().getDeclaredAnnotation(SomeAnnotationOnClass.class);
最後一行返回null。
new AgentBuilder.Default().with(AgentBuilder.Listener.StreamWriting.toSystemOut()).type(ElementMatchers.isAnnotatedWith(SomeAnnotationOnClass.class))
.transform((builder, type, clazzLoader, javaModule) -> {
return builder.method(ElementMatchers.any()).intercept(MethodDelegation.to(MyInterceptor.class));
這雖然有效......所以註釋是存在的(在課堂上!)。但不是當intercept()
被稱爲
謝謝! 有沒有關於如何在使用AgentBuilder時將轉換綁定到ParameterBinder.ForFixedValue的任何文檔? 我找不到任何。 – Reymanx
我想要的文檔少得多,但javadoc可以幫助你!你正在使用'MethodDelegation.withCustomBinding()。bind(...)。(...)'這個。 –