0
Android에서 ByteBuddy 클래스의 메소드를 대체 할 수 있습니까?Android에서 ByteBuddy로 MethodDelegation 가로 채기가 가능합니까?
public class DoSomething {
public void saySomething() {
Log.d("DoSomething", "Hello World");
}
}
public class ModifiedDoSomething {
public void saySomething() {
Log.d("ModifiedDoSomething", "Hello Injected");
}
}
new ByteBuddy()
.subclass(DoSomething.class)
.method(ElementMatchers.named("saySomething"))
.intercept(MethodDelegation.to(ModifiedDoSomething.class))
.make()
.load(DoSomething.class.getClassLoader(),
new AndroidClassLoadingStrategy(f))
.getLoaded()
.newInstance()
.saySomething();
이 코드를하려고하면, 그것은 예외 : 나는 FixedValue으로 차단하면
java.lang.IllegalArgumentException: None of [] allows for delegation from public void DoSomething.saySomething()
, 그것은 잘 작동하지만 나는 완전히 적어도 방법의 구현을 교체하거나해야 시작을 가로 채고, 원본을 부른 다음 끝에 다시 가로 챈다. ByteBuddy로 어떻게 든 가능합니까 아니면 대안이 있습니까?
감사