jeudi 12 juillet 2018

Alter method access to an argument using bytebuddy

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.





Aucun commentaire:

Enregistrer un commentaire