@Documented @Retention(value=RUNTIME) @Target(value=PARAMETER) public static @interface Advice.BoxedArguments
Indicates that the annotated parameter should be mapped to an array containing a (boxed) version of all arguments of the
method being instrumented. It is required that the annotated parameter is an array of type Object
.
Note that accessing this parameter is merely virtual. A new array is created on every access. As a result, changes to the
array have no effect other than for the local copy and when accessing the array twice, the equality relation does not hold.
For example, for @Advice.BoxedArguments Object[] foo
, the relation foo == foo
does not hold. For avoiding
new allocations, the array needs to be stored in a separate local variable. The variable itself is always read only.
Note: As the mapping is virtual, Byte Buddy might be required to reserve more space on the operand stack than the
optimal value when accessing this parameter. This does not normally matter as the additional space requirement is minimal.
However, if the runtime performance of class creation is secondary, one can require ASM to recompute the optimal frames by
setting ClassWriter.COMPUTE_MAXS
.
Advice
,
Advice.OnMethodEnter
,
Advice.OnMethodExit
Copyright © 2014–2016. All rights reserved.