I am working with byte buddy and I want to get values for all private fields in my intercepted class. I know that I can do something like this
public static boolean intercept(@Advice.FieldValue("fieldName") String fieldName)
My issue is that my interceptor works on multiple classes so the fields will vary. Is there a way to get all fields value for an intercepted class? Or maybe call the getter of those fields in my interceptor? The reason why I'm looking for @FieldValue is that I am using byte buddy on build time and I want to avoid having to use reflection on run time to get the field values or invoke the getter
You can register your own bindings for such purposes. This allows you to resolve a value once and extract it again and again.
The issue is that an array or a list cannot be represented as a conpile time constant, that implies allocation on each access. Therefore it is hard to create a general purpose mechanism.