0
我想攔截一個名爲methodA的方法,其中一個類型爲String的arg作爲打擊,我應該怎麼做。如何使用hasParameters()api?如何攔截具有特定參數的方法與bytebuddy
公共類演示{
public static void main(String[] args) {
new ByteBuddy()
.subclass(A.class)
.method(named("methodA").and(hasParameters(?)))
}
static class A {
public void methodA() {
System.out.println("methodA() invoked.");
}
public void methodA(String arg) {
System.out.println("methodA(" + arg + ") invoked.");
}
}
}
非常感謝你。我使用ElementMatchers.hasParameters方法並實現ElementMatcher>接口來達到我的目的,而且它工作的很好。 –
MengZhi