Search code examples
byte-buddy

Using ByteBuddy, how do I do the equivalent of MethodCall.invoke(someMethodDescription).onThis()?


MethodCall.invoke(someMethodDescription) returns an object on which I can, for example, invoke onSuper(). But there is no onThis(). What is the proper recipe to use if I want to invoke a virtual method on an instance of the class being defined?

If it matters, I'm using a subclassing strategy.


Solution

  • For virtual method calls, you can just omit the step and it implicitly invokes the method on the instance being instrumented.