Instrumentation . , Instrumentation.Compound , , FieldAccessor.ofBeanProperty() , , .
, Byte Buddy :
Instrumentation: . , , . , , .- A
ByteCodeAppender Instrumentation , , . - A
StackManipulation - . .
, ( this) . :
this MethodVariableAccess.REFERENCE.loadFromIndex(0).- , , . ,
ByteCodeAppender . TextConstant, . MethodInvocation, setChanged TypeDescription, Instrumentation.
, , Byte Buddy API - DSL Java. , Byte Buddy 0.4, , . , Byte Buddy, MethodDelegation. , Java .
, beans :
interface Changeable {
void setChanged(String field);
}
, :
class Interceptor {
static void intercept(@This Changeable thiz, @Origin Method method) {
thiz.setChanged(method.getName());
}
}
, Byte Buddy . , . this , .
, - . , Byte Buddy 0.4, Instrumentation :
MethodDelegation.to(Interceptor.class).andThen(FieldAccessor.ofBeanProperty())
Byte Buddy intercepor ( ) , , Instrumentation, andThen.