Annotation Type Advice.FieldValue
-
@Documented @Retention(RUNTIME) @Target(PARAMETER) public static @interface Advice.FieldValueIndicates that the annotated parameter should be mapped to a field in the scope of the instrumented type.
Setting
value()is optional. If the value is not set, the field value attempts to bind a setter's or getter's field if the intercepted method is an accessor method. Otherwise, the binding renders the target method to be an illegal candidate for binding.Important: Parameters with this option must not be used when from a constructor in combination with
Advice.OnMethodEnterand a non-static field where thethisreference is not available.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. This is however only relevant when writing to a non-static field.Important: Don't confuse this annotation with
FieldValueorMemberSubstitution.FieldValue. This annotation should be used only in combination withAdvice.- See Also:
Advice,Advice.OnMethodEnter,Advice.OnMethodExit
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>declaringTypeReturns the type that declares the field that should be mapped to the annotated parameter.booleanreadOnlyIndicates if it is possible to write to this parameter.Assigner.TypingtypingThe typing that should be applied when assigning the field value.java.lang.StringvalueReturns the name of the field.
-
-
-
-
declaringType
java.lang.Class<?> declaringType
Returns the type that declares the field that should be mapped to the annotated parameter. If this property is set tovoid, the field is looked up implicitly within the instrumented class's class hierarchy. The value can also be set toTargetTypein order to look up the type on the instrumented type.- Returns:
- The type that declares the field,
voidif this type should be determined implicitly orTargetTypefor the instrumented type.
- Default:
- void.class
-
-
-
readOnly
boolean readOnly
Indicates if it is possible to write to this parameter. If this property is set to
false, the annotated type must be equal to the type declaring the instrumented method if the typing is not also set toAssigner.Typing.DYNAMIC. If this property is set totrue, the annotated parameter can be any super type of the instrumented method's declaring type.Important: This property must be set to
trueif the advice method is not inlined.- Returns:
trueif this parameter is read-only.
- Default:
- true
-
-
-
typing
Assigner.Typing typing
The typing that should be applied when assigning the field value.- Returns:
- The typing to apply upon assignment.
- Default:
- net.bytebuddy.implementation.bytecode.assign.Assigner.Typing.STATIC
-
-