1
我想在运行时使用ByteBuddyAgent
注释默认方法。为了保持默认实现,我正在使用重定位策略,但我无法弄清楚如何通过调用原始方法来拦截新方法。如何重新绑定ByteBuddy的接口默认方法?
我试过使用MethodCall.invokeSuper()
和MethodCall.invokeSelf().onDefault()
,但都给我一个IllegalStateException
。
new ByteBuddy()
.subclass(MyInterface.class)
.method(isDeclaredBy(typeDescription).and(isDefaultMethod()))
.intercept(MethodCall.invokeSelf().onDefault())
.annotateMethod(AnnotationDescription.Builder
.ofType(MyAnnotation.class).build())
.make()
...