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.
Sorry, I missed that. The arguments are only virtual and therewith lazy by definition. Each read will create a new array. The following expression would therefore be false:
I have a more general Advice that looks like this:
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.