protected ByteCodeAppender . Size apply ( MethodVisitor methodVisitor , Context implementationContext , MethodDescription instrumentedMethod , StackManipulation preparingManipulation , FieldDescription fieldDescription ) { if ( instrumentedMethod . isStatic ( ) ) { throw new IllegalStateException ( "It is not possible to apply an invocation handler onto the static method " + instrumentedMethod ) ; } MethodConstant . CanCache methodConstant = privileged ? MethodConstant . ofPrivileged ( instrumentedMethod . asDefined ( ) ) : MethodConstant . of ( instrumentedMethod . asDefined ( ) ) ; StackManipulation . Size stackSize = new StackManipulation . Compound ( preparingManipulation , FieldAccess . forField ( fieldDescription ) . read ( ) , MethodVariableAccess . loadThis ( ) , cached ? methodConstant . cached ( ) : methodConstant , ArrayFactory . forType ( TypeDescription . Generic . OBJECT ) . withValues ( argumentValuesOf ( instrumentedMethod ) ) , MethodInvocation . invoke ( INVOCATION_HANDLER_TYPE . getDeclaredMethods ( ) . getOnly ( ) ) , assigner . assign ( TypeDescription . Generic . OBJECT , instrumentedMethod . getReturnType ( ) , Assigner . Typing . DYNAMIC ) , MethodReturn . of ( instrumentedMethod . getReturnType ( ) ) ) . apply ( methodVisitor , implementationContext ) ; return new ByteCodeAppender . Size ( stackSize . getMaximalSize ( ) , instrumentedMethod . getStackSize ( ) ) ; }
Applies an implementation that delegates to a invocation handler .