@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
Modifier and Type | Optional Element and Description |
---|---|
boolean |
readOnly
Determines if it should be possible to assign an array with boxed argument values of all parameters which replace the original
parameters.
|
public abstract boolean readOnly
Determines if it should be possible to assign an array with boxed argument values of all parameters which replace the original
parameters. If the assigned array has less arguments than the current methods has parameters, an ArrayIndexOutOfBoundsException
is thrown. It it contains incompatible types, a ClassCastException
is thrown.
Important: It is not possible to assign elements of the annotated array. Instead, an array needs to be assigned to the annotated parameter. This does not necessarily imply allocation overhead as local allocations are typically removed by the JVM's optimizer. Writing directly to the annotated parameter has no effect.
true
if it should be possible to assign an array of replacement arguments to the annotated parameter.Copyright © 2014–2016. All rights reserved.