@Documented @Retention(value=RUNTIME) @Target(value=PARAMETER) public static @interface Advice.BoxedReturn
Indicates that the annotated parameter should be mapped to a the return value where primitive types are boxed. For this
to be possible, the annotated parameter must be 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.BoxedReturn Object foo
, the relation foo == foo
does not necessarily hold for primitive
types. For avoiding additional 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 write to the boxed return value.
|
public abstract boolean readOnly
void
, the assigned value is
simply dropped.true
if it should be possible to write to the annotated parameter.Copyright © 2014–2016. All rights reserved.