Reputation: 1
I have a case like the example below
public String test(Trail trail) {
AnotherClass.access(trail);
this.executeAnotherMethod(trail);
futureCall(trail::end);
return "emptyString";
}
And I want to use byte-buddy to do something like this
public String test(Trail trail) {
Trail clonedTrail = trail.clone("test");
AnotherClass.access(clonedTrail);
this.executeAnotherMethod(clonedTrail);
futureCall(clonedTrail::end);
return "emptyString";
}
I have tried Advice
to intercept the call but that messed up object reference. I have been diving through byte-buddy testcases as well as reading ASM, but haven't made great progress so far.
Upvotes: 0
Views: 303
Reputation: 44032
This can be done with advice by overwriting the argument.
@Advice.OnMethodEnter
static void enter(@Advice.Argument(readOnly = false) Trail trail) {
trail = trail.clone("test");
}
Upvotes: 0