In Advice, this is not supported straight forward. The reason is that code is added to the method at the beginning and end, so the original code does no longer exist as an invocation unit. However, you can easily emulate it:
The idea is that you first jump over to exit advice. Then you do your thing and if you want to invoke the original code you "repeat" the method invocation. For this you leave the exit advice and Byte Buddy will jump back to the beginning of the method. You can also use a reference value such as a string, or an integer as a counter. If you then return null or 0 (or false as in the example), you finally leave the original code.
In
Advice
, this is not supported straight forward. The reason is that code is added to the method at the beginning and end, so the original code does no longer exist as an invocation unit. However, you can easily emulate it:The idea is that you first jump over to exit advice. Then you do your thing and if you want to invoke the original code you "repeat" the method invocation. For this you leave the exit advice and Byte Buddy will jump back to the beginning of the method. You can also use a reference value such as a string, or an integer as a counter. If you then return null or
0
(orfalse
as in the example), you finally leave the original code.