byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

Is it possible to lazily instantiate AllArguments?

Open dogourd opened this issue 1 year ago • 0 comments

I have a more general Advice that looks like this:

public class Advice {
    @OnMethodEnter
    public static void before(@AllArguments Object[] args) {
         if (xxxx) {
             return;
         }
         if (xxxx) {
             return;
         }
         // use the args.
         Arrays.toString(args);
    }
}

There are many logical branches inside Advice that do not pay attention to parameters information, but the generated bytecode will always copy the original parameter list into an array and assign it to the args parameter.

Can I use bytebuddy to implement lazy instantiation of AllArguments? Make sure I only actually create the target array when I'm actually going to use it.

dogourd avatar May 14 '24 13:05 dogourd