Can we add a new injection mode that can inject gotos?
For example, original code:
class X {
int foo(int x) {
if (x < 0) return -x;
bar(x)
return x;
}
}
then
@Goto(method="foo", at = @At(value = "INVOKE", target = "bar...", shift = BEFORE), to = @At(value = "INVOKE", target = "bar...", shift = AFTER)
boolean condition() {
return true; // if return true, goto the "to" target, otherwise, do nothing. This is like if statement.
}
Finally, the code is like
class X {
int foo(int x) {
if (x < 0) return -x;
if (condition()) {
// nothing
} else {
bar(x);
}
return x;
}
}
I know this may be unnecessary because @Redirect is already here, but @Redirects often cause a lot of conflicts. Many redirects just add a condition, if we provide a compatible method to do that, we can reduce conflicts. What's more, this feature can support break and continue, which is also very useful i think.
Can we add a new injection mode that can inject
goto
s?For example, original code:
then
Finally, the code is like
Its definition may be like:
I know this may be unnecessary because
@Redirect
is already here, but@Redirect
s often cause a lot of conflicts. Many redirects just add a condition, if we provide a compatible method to do that, we can reduce conflicts. What's more, this feature can supportbreak
andcontinue
, which is also very useful i think.